web-config

IIS Rewrite Rule in web.config to redirect HTTPS requests to HTTP

烈酒焚心 提交于 2019-12-18 16:51:18
问题 I need to redirect all https requests to http, for example, if someone visits https://www.example.com/another-page/ to http://www.example.com/another-page/ I have the following rewrite rule in my web.config right now, but it's not working correctly. It's redirecting https://www.example.com/another-page/ to https://www.example.com/, so to the root of the site, but instead I want the redirect to stay in the same URL and only rewrite https to http. <rule name="Redirect to HTTP" stopProcessing=

Change URL Rewrite Rule in Web.Config from Code C#

大兔子大兔子 提交于 2019-12-18 15:40:08
问题 I want to modify rewrite rule from C# code. Url Rewrite rule is resides in web.config file. <system.webServer> <rewrite> <rules> <rule name="partners"> <match url="^partners$" /> <action type="Rewrite" url="partners.aspx" /> </rule> <rule name="news"> <match url="^news$" /> <action type="Rewrite" url="news.aspx" /> </rule> <rule name="projects"> <match url="^projects$" /> <action type="Rewrite" url="projects.aspx" /> </rule> </rules> </rewrite> </system.webServer> I want to change for ex.

How is the property in webconfig maxRequestLength measured

坚强是说给别人听的谎言 提交于 2019-12-18 14:09:11
问题 I would like to increase this value <httpRuntime maxRequestLength="2024000" executionTimeout="300"/> But i am not sure how it is measured, MB, KB? not sure. I would like to be able to accept requests up to 50 MB. Regards 回答1: The property maxRequestLength indicates the maximum file upload size supported by ASP.NET. This limit can be used to prevent denial of service attacks caused by users posting large files to the server. The size specified is in kilobytes. The default is 4096 KB (4 MB).

How to restrict download of specified file types

六眼飞鱼酱① 提交于 2019-12-18 13:53:19
问题 I want to restrict my web app so that .txt files can not be downloaded/shown. Is this something I can set up in my web.config file? I tried this in my config file: <system.web> <httpHandlers> <add verb="*" path="*.txt" type="System.Web.HttpForbiddenHandler" /> </httpHandlers> </system.web> ...but it had no effect. I am using IIS7 and application is .NET3.5, could this have something to do with it? I know this would actually work for .NEt 1.0 1.1 and 2.0. I noticed in the documentation for

Filter on exception text in elmah

╄→гoц情女王★ 提交于 2019-12-18 13:39:13
问题 Is there a way to filter exceptions in elma using the exception message? Examples: "System.Web.HttpException: Request timed out." I don't want to filter out all HttpException, but only the timed-out requests. "System.Web.HttpException: Maximum request length exceeded." What I don't want to do is write own code for that. So is it possible to do this with the buildin-web.config configuration? Thank you! 回答1: Yes you can. Just use a regular expression to interrogate the message. See the example

Custom Error Handling in web.config / Global.asax not handling non-existant directory

人走茶凉 提交于 2019-12-18 12:31:49
问题 Question is: Why is custom Error handling not working for non-existing paths/directories? Updated with fixed code (thanks to everyone for you input): * Updated code for web.config and global.asax * <httpErrors errorMode="Custom"> <remove statusCode="500" subStatusCode="-1" /> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/*****.aspx" responseMode="ExecuteURL" /> <error statusCode="500" subStatusCode="-1"

Custom Error Handling in web.config / Global.asax not handling non-existant directory

混江龙づ霸主 提交于 2019-12-18 12:30:18
问题 Question is: Why is custom Error handling not working for non-existing paths/directories? Updated with fixed code (thanks to everyone for you input): * Updated code for web.config and global.asax * <httpErrors errorMode="Custom"> <remove statusCode="500" subStatusCode="-1" /> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/*****.aspx" responseMode="ExecuteURL" /> <error statusCode="500" subStatusCode="-1"

Authorization using active directory role provider MVC4

笑着哭i 提交于 2019-12-18 12:17:32
问题 I'm building a MVC4 application for internal use in a corporate enviroment. I use windows authentication, which works fine, but I'm having troubles using Active Directory groups as roles for authorization. My Web.config looks like this: <authentication mode="Windows" /> <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"> <providers> <clear /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> <

How to configure WCF services to work through HTTPS without HTTP binding?

为君一笑 提交于 2019-12-18 12:14:19
问题 I have configured my WCF services to work with SSL but it works ONLY if the HTTP binding exists in the IIS Web Site. When the HTTP binding not exists and exists only HTTPS binding I get the following error: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address. How can I resolve this issue? Thanks. 回答1: Modify your

ASP.NET MVC3: Debug and Release app settings not working [duplicate]

柔情痞子 提交于 2019-12-18 11:18:29
问题 This question already has answers here : How can I use Web.debug.config in the built-in visual studio debugger server? (7 answers) Closed 5 years ago . My debug and release web.config app settings are not being read correctly. Web.config: <appSettings> <add key="webpages:Version" value="1.0.0.0"/> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> </appSettings> Web.Debug.config <appSettings> <add key="ErrorEmailAddress" value=