asp.net-4.0

Redirect all naked domain urls to subdomain(www) urls preserving the url, except for one page on IIS/ASP.NET

依然范特西╮ 提交于 2019-12-10 09:24:38
问题 Whats the best way to achieve the above? I do know that it can be achieved at HttpModule level. Is it possible just via web.config(easier and faster to code execute). 回答1: It's easy to do this with the URL rewrite module through the web.config : <rewrite> <rules> <clear /> <rule name="Redirect naked domains to www.domain.com" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" negate="true" pattern="^www\." /> <add input="{REQUEST_URI}"

Get description for HTTP status code

随声附和 提交于 2019-12-10 01:12:00
问题 In ASP.NET you can set the Response.StatusCode to for example 404. Should the status line / description always be set? (to in this case "404 Page Not Found") How do you get the description if you only have the code (404)? Is this somewhere in the framework or do you manually have to hardcode the descriptions? 回答1: You can use the static method HttpWorkerRequest.GetStatusDescription for this. 回答2: If you need it at the same time you're pulling Response.StatusCode, you can get the description

InitializeCulture() on every single page necessary?

我们两清 提交于 2019-12-10 00:00:55
问题 I have a web forms site that needs to be localized. I mean, it is localized, I just need to set the right language according to the domain. Something like: protected override void InitializeCulture() { var i = Request.Url.Host.ToLower(); var domain = i.Substring(i.Length - 2, 2); if (domain == "se") { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("sv-SE"); } else if (domain == "dk") { Thread

HTTP Error 503. The service is unavailable under simple ASP.NET 4.0 web site

独自空忆成欢 提交于 2019-12-09 07:33:26
问题 Something strange happened on my local laptop: my web site that worked locally for a long isn't launched... Trying to localize the problem I've created a simple web site with 'index.html' file only. It works fine under ASP.NET 2.0, but when I switched App Pool to use 4.0 - it stopped to work. When I open web site in browser it shows the following error: Service Unavailable HTTP Error 503. The service is unavailable. And causes App pool to stop work also... In the system event log in

Autopost back in mvc drop down list

旧巷老猫 提交于 2019-12-08 23:56:35
问题 Requirment: I have a drop down list on my view page, displaying a list of vendors. When a vendor is selected from the dropdown, the page displays the details of selected vendor. By default i need to keep first vendor selected and its details displayed. I could accomplish this by using following code. Problem: Dont know how to accomplish autopostback = true in MVC. I need to display the details of selected vendor on selection of vendor in the dropdown list. I am using ASP.net 4.0, MVC3, Entity

Duplicate type error?

心不动则不痛 提交于 2019-12-08 19:18:08
问题 We have been having a random issue with our live website. We're not sure what exactly is causing the issue. We tried clearing the temporary files but the issue happened again. We even killed the IIS app_pool so that it wouldn't be holding any of them in memory. As soon as we put the site back up we get this error again. Compiler Error Message: CS0433: The type 'ASP.modules_dataentry_provider_orderhistory_ascx' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET

Force by config to use tls 1.0 in a wcf client c#

浪子不回头ぞ 提交于 2019-12-08 17:38:14
问题 We have a web app that has a client implemented with WCF. This client uses SSL_LVL3 to make the handshake with an external service. It turns out that the service just disabled the SSL_LVL3, so we need to change it to TLS 1.0. There is a way to force TLS security in C#: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; But it changes the security of all the services that are used by the app and not all the services accept TLS. What we would like is to change the web.config to

Merging the table from 3 dataset to 1

一个人想着一个人 提交于 2019-12-08 12:18:08
问题 I am loading three dataset from the database which has Dataset 1 > Table 1 > 10 rows Dataset 2 > Table 1 > 3 rows Dataset 3 > Table 1 > 5 rows (All dataset has same column name, same datatype) actually they contains the data based on different select condition) now I want to merge all three dataset into one like this Dataset 4 > Table 1 > 18 rows Please help how can I do it 回答1: Try the DataSet.Merge Method (DataSet) method. Something like this (not tested): C#: dataset1.Merge(dataset2);

Is DiskCacheProvider in ASP.Net 4.0 really exist?

ぐ巨炮叔叔 提交于 2019-12-08 11:26:14
问题 I read many places said the new feature in ASP.net 4.0, and the code is: <caching> <outputCache defaultProvider="AspNetInternalProvider"> <providers> <add name="DiskCache" type="test.OutputCacheEx.DiskOutputCacheProvider, DiskCacheProvider"/> </providers> </outputCache> </caching> Anyway, I cannot get it work, I change the code inside out, no use. I cannot only find 1 cache provider from Microsoft which shipping with asp.net is AspNetInternalProvider So, Is DiskOutputCacheProvider really

Threading for methods on button click

筅森魡賤 提交于 2019-12-08 05:52:19
问题 I am calling few methods on a button click. functionA() functionB() functionC() All three functions are independent from each other and they take long time to execute. I checked and found that by threading I can run all three together which will save the execution time. As I am new to threading concept, could anyone please guide me the simplest way I can do threading in scenario or other way which will be useful in this scenario. EDIT One more problem in the same function: I am binding 5