Tag: iis

找不到Microsoft.AspNetCore.Antiforgery

我正在将IIS.net核心2.0网站部署到IIS 10。 我确保我的应用程序在program.settings文件中使用了正确的ISS配置。 public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() .Build(); } 在我的startup.cs文件中: public void ConfigureServices(IServiceCollection services) { services.Configure(options => { }); services.AddMvc(); } 然而,当我从命令行运行dotnet website.dll时,我收到命令行窗口中显示的以下错误消息: 未找到应用程序依赖项清单(website.deps.json)中指定的程序集:package:’Microsoft.AspNetCore.Antiforgery’,version:’2.0.1’path:’lib / netstandard2.0 / Microsoft.AspNetCore.Antiforgery .dll’当使用以下目标清单文件发布应用程序时,此程序集应位于本地运行时存储中:aspnetcore-store-2.0.3.xml 基于错误消息,我猜测Microsoft.AspNetCore.Antiforgery在我发布时没有捆绑,因为我在调试时没有收到此错误。 如何确保我的应用程序在发布到实时环境时能够找到Microsoft.AspNetCore.Antiforgery? 编辑:这是一个基本的.net核心网站。 除了使用IIS进行部署的上述更改之外,此时未对标准项目进行任何更改。 当我从IIS而不是命令行运行项目时,我收到502.5错误消息。

WCF Web服务的响应大小限制

我使用basicHttpBinding在IIS中托管WCF服务。 WCF Web服务使用ADO.Net查询后端SQL Server 2008,并将DataTable返回到WCF服务的客户端。 我发现当返回的DataTable很大时,会有exception表示http连接被IIS关闭。 任何想法有什么问题以及如何设置更大的响应大小? 另一个想法是对象的序列化大小是否有任何硬性限制(我想也许DataTable实例太大而不能序列化?) IIS返回的错误信息是: exception消息: 收到http://labmachine1/service.svc的HTTP响应时发生错误。 这可能是由于服务端点绑定不使用HTTP协议。 这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭)。 请参阅服务器日志以获取更多详 {“底层连接已关闭:接收时发生意外错误。”} 这是我的服务器端的完整源代码,对于我在web.config中托管的服务器,默认值没有变化。 由于我在IIS中托管,我使用basicHttpBinding。 public class StudentManagement : IStudentManagement { public DataTable Poll(int Id) { return MakeParentTable(); } private DataTable MakeParentTable() { // Create a new DataTable. System.Data.DataTable table = new DataTable(“ParentTable”); // Declare variables for DataColumn and DataRow objects. DataColumn column; […]

如何从C#更改IIS中ApplicationPool的用户名/密码?

我使用下面的代码在我的应用程序的Installer类中创建一个新的应用程序池: private static void CreateAppPool(string serverName, string appPoolName) { // metabasePath is of the form “IIS:///W3SVC/AppPools” // for example “IIS://localhost/W3SVC/AppPools” // appPoolName is of the form “”, for example, “MyAppPool” string metabasePath = string.Format(“IIS://{0}/W3SVC/AppPools”, serverName); Console.WriteLine(“\nCreating application pool named {0}/{1}:”, metabasePath, appPoolName); try { DirectoryEntry apppools = new DirectoryEntry(metabasePath); DirectoryEntry newpool = apppools.Children.Add(appPoolName, “IIsApplicationPool”); newpool.CommitChanges(); […]

IIS下的多个端点

我一直在尝试在IIS下托管的服务中添加新端点,但过去一天左右无法弄清楚。 这是我的理解: 您可以在IIS下拥有多个端点,只要它们具有唯一的地址即可。 您可以分配一个基地址,但它将被IIS中的虚拟目录设置覆盖。 我的虚拟目录是http:// localhost / WcfCert / 我可以使用http://localhost/wcfcert/service1.svc启动服务 但http://localhost/wcfcert/test/service1.svc/test在IE或客户端应用程序中不返回任何内容 我在这里错过了什么? 编辑: 所以我做了进一步的测试,这就是我发现的。 如果我启动WcfTestClient.exe并添加http:// localhost:1523 / Service1.svc或http:// localhost:1523 / Service1.svc / mex ,它将在该地址下添加两个端点。 所以这里是我的问题不应该http:// localhost:1523 / Service1.svc只代表第一个端点? 为什么添加该地址会带来两个端点? 但如果我尝试添加http:// localhost:1523 / Service1.svc / test我得到 错误:无法从http:// localhost:1523 / Service1.svc / test获取元数据如果这是您有权访问的Windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布。 有关启用元数据发布的帮助,请参阅http://go.microsoft.com/fwlink/?LinkId=65455上的MSDN文档.WS-Metadata Exchange错误URI: http:// localhost:1523 / Service1.svc / test元数据包含无法解析的引用:’ http:// localhost:1523 / Service1.svc / […]

HTTP错误414.请求URL太长。 asp.net

我收到错误“HTTP错误414.请求URL太长。” 从以下文章中,我了解到这是由于查询字符串非常长: Solution for Query String Too Long Error 在web.config中,我有maxQueryStringLength=”2097151″ 。 这是最大值吗? 为了解决这个问题,我应该在web.config中设置maxUrl吗? 如果是这样,支持的最大值是多少? 我该怎么做才能解决这个错误?

如何使用自定义IHttpModule和HttpRequestfilter修改POST请求?

概观 我希望能够将请求参数和内容修改为第三方Web服务(ArcGIS Server)。 这将用于创建存在于任何客户端应用程序和服务器应用程序之间的安全层。 我认为我找到了一个解决方案,但我目前在实施方面遇到了一些困难。 可能的解决方案:使用自定义请求筛选器修改请求 对于解决方案,我基于MSDN上显示的示例松散地实现了自定义请求filter。 我已经“增强”了代码,以便我可以使用正则表达式搜索和替换必要的内容。 这包括: 将内容(存储在字节数组中)转换为字符串。 搜索字符串并执行任何必要的修改。 将修改后的字符串转换为字节数组并将其写入缓冲区。 一个例子如下所示: public override int Read(byte[] buffer, int offset, int count) { int bytesRead = _stream.Read(buffer, offset, count); string orgContent = Encoding.UTF8.GetString(buffer, offset, bytesRead); string orgContentDecoded = HttpUtility.UrlDecode(orgContent); string layersPattern = @”&layers=(show|hide|include|exclude):([0-9]+,?)+”; Regex layersRegex = new Regex(layersPattern, RegexOptions.IgnoreCase); string[] permittedLayers = new string[] { […]

发布到IIS 7.5时,ASP.NET Core 404错误

我正在使用Visual Studio 2015将我的ASP.NET核心应用程序发布到IIS 7.5。 我要做的就是在我的wwwroot中查看正常的default.htm页面。 当我使用VS的IIS Express时,一切正常,但是当我发布到IIS 7.5并指向Visual Studio在发布时创建的wwwroot文件夹的物理路径时,我只得到一个空白屏幕(404)。 有什么奇怪的是当我从startup.cs的Configure方法中运行默认的app.run方法时,它完美地工作: app.Run(async (context) => { await context.Response.WriteAsync(“Hello World!”); }); 但是,当我评论出来时,使用app.UseDefaultFiles()和app.UseStaticFiles(),我什么都没得到。 这是我的Startup.cs文件: public class Startup { // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void […]

在IIS中重新启动应用程序池时立即运行Application_Start

我们正在应用程序的application_start阶段进行一些缓存操作。 因此,当应用程序池重新启动时,所有缓存都将消失。 是否可以在应用程序池重新启动时触发application_start,或者您是否有更好的想法来解决此问题?

AppDomain.CurrentDomain.UnhandledException未被调用

我有一个WCF服务,在Global.asax中有以下代码: protected void Application_Start(object sender, EventArgs e) { // Make sure that any exceptions that we don’t handle at least get logged. AppDomain.CurrentDomain.UnhandledException += LogUnhandledException; } private void LogUnhandledException(object sender, UnhandledExceptionEventArgs e) { Log.Error.LogException(“UnhandledException”, e.ExceptionObject as Exception); } 我们的想法是至少记录所有未公开的exception。 但它似乎从未被称为。 我尝试在我的一个服务操作中执行Divide by Zero,它只是在遇到exception后停止服务。 int zero = 0; int result = 100 / zero; 永远不会调用LogUnhandledException方法。 我在IIS中运行并在调试器中运行。 […]

没有IIS的主机MVC Web应用程序

我有一个Asp.net MVC 3应用程序,我想让用户使用它而不必在IIS中运行它来运行它。 我想要的是他们点击的某种可执行文件或托管应用程序的服务,然后他们可以从网络上的任何浏览器使用它。 我有什么选择?