web-config

specifying MaxHttpCollectionKeys for a specific page?

喜欢而已 提交于 2019-12-19 20:39:09
问题 I am wondering if there is a way to change this value for a particular page, instead of setting it for the entire project. We are running into the limit, but only for a couple pages. Our project is using .NET 3.5. For those who are unaware of what this variable is for, it is to get around this: http://support.microsoft.com/kb/2661403 Essentially if you have a lot of form keys (over 1000), you will get an exception when posting back to the page. You can get around this by specifying in your

How to set default time zone in ASP.Net Application

烂漫一生 提交于 2019-12-19 17:40:32
问题 Hi i have created the asp.net web application without considering the time zone. I am using directly the DateTime.Now function. Actually that returns datetime in server configured time zone format. Now i cant change entire application. so is there any way set the TimeZone of application independent of server in which it is hosted? or is there any way to set in web config file. 回答1: TimeZone.CurrentTimeZone is used for the time zone on the computer where the code is executing. Check these

Asp.net core 2.0 website, cache-control not working as expected

蓝咒 提交于 2019-12-19 11:34:35
问题 In my asp.net core 2.0 application, I am trying to add expiration header (cache-control) into response header for all static resources but it's not adding it all. Below is my code public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddMvc().AddJsonOptions(jsonOptions => { jsonOptions.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; // handle loops correctly jsonOptions.SerializerSettings.ReferenceLoopHandling =

A web site code can't connect to a soap service on the same server

…衆ロ難τιáo~ 提交于 2019-12-19 11:32:16
问题 My ASP.NET web site calls a .net service from a code in App_Code to retrieve some information. The web service is hosted at http://mydomain/ws/DirectoryService.asmx . Whenever I deploy a web site on any server other then the same server that the required .net service is hosted on, everything works good. Whenever I deploy the site to the same web server, that the web service is hosted on, I get 401.1 error. I have the following binding defined in web.config of the site: <system.serviceModel>

Encrypting AppSettings in file external to Web.Config

自作多情 提交于 2019-12-19 05:33:13
问题 I currently use this method to encrypt the AppSettings section of my application's web.config file: aspnet_regiis.exe -pe "appSettings" -site "MySite" -app "/" But now I have moved some settings out to another file using the element <appSettings file="IndividualAppSettings.config" > I can still encrypt the app setting in the web.config, but is there any way to encrypt the content of the additional IndividualAppSettings.config file? 回答1: We do this all the time as we use external files for

Custom error pages for non-existant directory/file Web API (not controllers)

[亡魂溺海] 提交于 2019-12-19 04:37:20
问题 I know I can have custom error pages for non existent controllers or wrong routing but how can I show custom error pages if an user tries to download a file that does not exist inside some directory? I can't make it work at all. It's still showing default error page. 回答1: This blog post walks you through handling 404 errors in ASP.Net Web API: http://weblogs.asp.net/imranbaloch/handling-http-404-error-in-asp-net-web-api Let's say that you are developing a HTTP RESTful application using ASP

Creating virtual application/directory in physical folder on IIS/ASP.NET

丶灬走出姿态 提交于 2019-12-19 03:44:11
问题 What I want to achieve is simple: I have a website, say "my-site" - http://localhost In this website I have a (physical) folder "foo" - http://localhost/foo Inside the "foo"-folder I want to have a virtual directory (application?) called "upload", so the URL becomes http://localhost/foo/upload Notice that "my-site" is an empty website with a bunch of folders in it, "foo", "bar", "baz", etc. So when I right click on "foo" and choose "New > virtual directory" and add my application I've written

Different connection string for each publish profile in VS2010

末鹿安然 提交于 2019-12-19 03:25:16
问题 Is it possible to change connection string (or just server host) relying on selected web publish profile? Maybe using Web.config transform or someway else? I mean for profile "Test" change connection string "MyConnString" (in published Web.config) to "Data Source='example.com,14333;..." and for profile "Production" - to "Data Source=./SQLExpress;..." 回答1: This is exactly what web config transforms were created for. The link you provided in your post has a walkthrough of doing this

Web.config transformation: how to apply a transformation to all node matching a Locator expression?

我只是一个虾纸丫 提交于 2019-12-19 00:09:11
问题 I've recently discovered the web.config automatic transformation in the web deploy tool of visual studio 2010. It's working well, but I have a scenario I can't seem to get working. Assume I have the following root Web.config <services> <service name="Service1"> <endpoint address="" binding="customBinding" bindingConfiguration="LargeBufferBinding" contract="Service1" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> <service name="Service2">

How can I handle maxRequestLength exceptions elegantly?

一世执手 提交于 2019-12-18 17:56:15
问题 In my ASP.NET MVC (v2 if it matters) app, I have a page that allows the user to upload a file. I've configured the maxRequestLength for my app to allow files up to 25MB. As a test, I send it a 500MB file which throws the exception: Maximum request length exceeded. (I only know this because ELMAH catches the error and logs it.) In my web.config, I've set customErrors mode="On" with a defaultRedirect , but the user isn't redirected at all, they don't even get a yellow-screen-of-death. In Chrome