asp.net-4.0

IntegrationTests - A potentially dangerous Request.Path value was detected from the client

谁都会走 提交于 2019-12-05 02:18:04
问题 I get this error: A potentially dangerous Request.Path value was detected from the client (?). when this URI: http://www.site.com/%3f . How can I write an integration tests around of all of this type of errors? I want to test against all this erros: A potentially dangerous Request.Path value was detected from the client A potentially dangerous Request.Cookies value was detected from the client A potentially dangerous Request.Form value was detected from the client A potentially dangerous

ASP.NET 4.0 DropDownList with single quotes in text

心不动则不痛 提交于 2019-12-04 23:17:27
问题 We have a asp:DropDownList that we populate server side with ddlBranch.Items.Add(new ListItem("TEST","This is a's test")); When this is compiled and run under .NET 3.5 we see the text "This is a's test" However when this is compiled and run under .NET 4.0 we see the text "This is a ' s test" We have added the following to our web.config and there was no change. <pages controlRenderingCompatibilityVersion="3.5" /> For the time being we have dropped back to .NET 3.5 however we would like to

Hide a GridView column by name at runtime in ASP.Net

半世苍凉 提交于 2019-12-04 22:35:33
Is it possible to show/hide a GridView column at runtime by name? I can do it via the index like the following: gridReviews.Columns[4].Visible = false; However I'd like to do the following: gridReviews.Columns["Name"].Visible = false; What's the best way to do this? You can use the following code for it: foreach (DataControlField col in gridReviews.Columns) { if (col.HeaderText == "Name") { col.Visible = false; } } You can access the gridview by column name indirectly if you can access the data you used to bind the gridview and the gridview columns are in the same order as the datatable (and

InitializeCulture() on every single page necessary?

佐手、 提交于 2019-12-04 19:40:09
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.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("da-DK"); Thread.CurrentThread.CurrentUICulture

Reading .NET 4.0 dump files in WinDBG

安稳与你 提交于 2019-12-04 18:33:51
I'm familiar with the WinDBG paradigm. Been reviewing a lot of dump files using WinDBG x64 version. For the most part dump files were .NET 2.0 applications and psscor2.dll. Current WinDBG version I am using is 6.12.0002.633. Recently, I've been trying to open x64 dump IIS dump files generated from a .NET 4.0 application pool using psscor4.dll. Any command I run returns, "Failed to request information" I've mscordacwks.dll from c:\Windows\Microsoft.NET\Framework64\v4.0.30319 on the server Renamed to mscordackwks_AMD64_AMD64_4.0.30319.xxxx.dll. xxxx matches the compiled version in the file Open

IIS 7.5 ASP.NET-4 Gzip compression

吃可爱长大的小学妹 提交于 2019-12-04 18:14:16
问题 I just can't seem to get GZIP compression enabled for my ASP.NET 4 application. Only javascript files seem to get compressed. The page, css and others dont get compressed. The response header of a not compressed CSS file is: Content-Type text/css Last-Modified Mon, 09 Aug 2010 20:10:34 GMT Accept-Ranges bytes Etag "5d71bdecfe37cb1:0" Server Microsoft-IIS/7.5 Date Sat, 28 Aug 2010 14:33:56 GMT Content-Length 3364 And for a Javascript file that gets compressed (scriptresource.axd): Cache

maxRequestPathLength not in ASP.NET 4 documentation and doesn't work

自闭症网瘾萝莉.ら 提交于 2019-12-04 17:57:55
If I try to use the new maxRequestPathLength settings in an ASP.NET application it does not work. I get an unrecognized attribute error. I've tried using both ASP.NET Integrated and Classic application pools in IIS 7. What is also funny is that if you search for maxRequestPathLength on MSDN it is no where to be found in the documentation except in the list of new features for ASP.NET 4. What gives? I've been struggling with this and with help of this post en several other forum post made it work for me. Here is my log and findings: To allow longer url's then default, just change this in your

Launching a long-running background task - from ASP.NET or a scheduled job

落爺英雄遲暮 提交于 2019-12-04 16:27:22
I have a fairly long-running process (several minutes) that I need to run roughly once a month - but not on a fixed schedule, but after a user clicks Go in a ASP.NET Webforms GUI page. Since ASP.NET really isn't designed to handle long-running background tasks, my idea was to put this into a separate console app. But how to launch that as needed? What happens if I use Process.Start(....) from my ASP.NET page's code-behind? I would like to avoid blocking the whole Web UI for 20 minutes or so... and also: even if it doesn't block my UI, what happens to my long-running task if the ASP.NET app

Creating a class like ASP.NET MVC 3 ViewBag?

烈酒焚心 提交于 2019-12-04 16:06:38
问题 I have a situation where I would like to do something simular to what was done with the ASP.NET MVC 3 ViewBag object where properties are created at runtime? Or is it at compile time? Anyway I was wondering how to go about creating an object with this behaviour? 回答1: Use an object of type dynamic . See this article for more information. 回答2: I created something like this: public class MyBag : DynamicObject { private readonly Dictionary<string, dynamic> _properties = new Dictionary<string,

Stopping XSS when using WebAPI

倾然丶 夕夏残阳落幕 提交于 2019-12-04 11:18:46
问题 I have a controller which accepts public class MyModel { [MaxLength(400)] public string Message { get; set; } } I have a WebApi Post Action public HttpResponseMessage Post(MyModel viewModel) { if (!ModelState.IsValid) return new HttpResponseMessage(HttpStatusCode.BadRequest); ... } And a get action. Since the content is written out by javascript rather than directly in a view the exact content was getting written out, also no asp.net warnings about dangerous content kicked in. I want to