Request.RawURL not set to default.aspx at application root - asp.net

I have just upgraded my ASP.NET application from .NET 3.5 to 4.0 and have found that the Request.RawURL is set to "/" when requesting the default document, default.aspx, via http://mysite.com/. In .NET 3.5, the Request.RawURL would be set to "/default.aspx".
Is there any way to enable this .NET 3.5 behavior in 4.0?
I have tried disabling extensionless URLs via the registry. I also went through the ASP.NET 4.0 Breaking Changes doc and have set the form tag action attribute, however viewing the source of the page shows that the value set for the action attribute is not being picked up and is reverting back to "/".
Currently running on IIS 7.5 integrated mode and Win7.

Indeed, I can reproduce the behavior when switching between .NET 2.0 and .NET 4.0 -- .NET 2.0 & 3.5 both share the same Common Language Runtime CLR2, with additions to the base class library (BCL) for the higher versions of .NET. With .NET 4.0 came CLR4 and that seems to be where the difference occurs. I never noticed that before!
I believe the new behavior is correct, as RawUrl reflects the URL path that was actually requested. It's difficult to understand your exact need, but I think you might try using Request.Path instead.
URL: http://example.com/
Request.RawUrl: /
Request.Path: /default.aspx
Perhaps you can elaborate a bit more on your application?

Related

SSO not working after .NET 4.5.1 update?

We have two server running .NET 4.5.1 and one running .NET 4.0. Before updating the first two, our SSO for forms authentication worked fine. Now, a user will appear authenticated on those first two servers, but not authenticated on the .NET 4.0 box.
All machine keys, decryption keys, cookie domains, etc, are all the same. No code was modified. We simply applied the 4.5.1 update to those two servers.
I've noticed for the 4.0 server, while our authentication cookie IS being passed up, it's not being recognized by the code (I threw a test page on the site and outputted some variables).
Has machine key encryption changed between 4.0 and 4.5.1? Do I need to apply some patch? Thanks.
The encryption APIs have changed in 4.5 see this blog post for more detail - http://blogs.msdn.com/b/webdev/archive/2012/10/23/cryptographic-improvements-in-asp-net-4-5-pt-2.aspx
According to MS simply upgrading to 4.5 wouldn't affect the apps unless the web.configs have changed to target 4.5 which seems odd in your case. You can try adding this attribute to each web.config to force .NET 2.0 compatibility-
<machineKey compatibilityMode="Framework20SP1" />

Targeting .NET 2.0 & 4.0 in web.config

I have a web application that usually runs with a .NET 2.0 AppPool account. But because the AJAX calls posts string serialized XML to the server, I needed to add the "requestValidationMode" option to the httpRuntime setting when running the same AppPool account with .NET 4.0.
However, switching back to .NET 2.0, the application responds with error with regards to the "requestValidationMode" option.
Is there a way one can have one web.config with some conditional mark-up so one need not edit the web.config each time the version of .NET is changed for the AppPool?
Any help would be greatly appreciated.

Legacy ActiveX Control with .NET 4.0 - Microsoft POS

We have an ActiveX Control calling Microsoft Point of Sale for .NET. However POS doesn't work with .NET 4.0 due to CAS (Code Access Security) which is obsolete for .NET 4.0.
The best resource I've found is on this LavaBlast Blog, however I've been unable to get it to work.
At what point should I be setting this? I didn't think ActiveX controls had configuration files associated with them for this setting, and wouldn't this be a setting on the user's computer and not on a webserver's web.config file?
Here is the code and the specific error:
PosExplorer explorer = new PosExplorer();
This method explicitly uses CAS policy, which has been obsoleted by
the .NET Framework. In order to enable CAS policy for compatibility
reasons, please use the NetFx40_LegacySecurityPolicy configuration
switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570

The correct way to validate request in asp.net 4.0

I've been adding
requestValidationMode="2.0"
to my web.config files ever since .net 4.0 came out, but it seems to me that setting the validation mode back to 2 versions prior seems a little silly. So in .net 4, what is the correct way of managing the request validation?
The correct way, in my opinion, is to let it be and don't mess with it, unless you have a good reason. Default value in version 4.0 is, wait for it, 4.0 :)
Please see this for more information:
http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.requestvalidationmode.aspx
and especially this article:
ASP.NET 4 Breaking Changes
The basic difference is this:
2.0 - validation occurs only for asp.net pages
4.0 - validation occurs for every http request (services etc.)

Migration: ASP.NET 1.1 to ASP.NET 2.0, broken postback

We just recently migrated our web application from .NET 1.1 to .NET 2.0.
The web application was originally written in .NET 1.1 using Visual Studio 2003. To migrate it, we converted the solutions to VS2005.
Aside from some minor problems like RESX incompatibility and broken Calendar Controls, the Web Application worked.
However, we just tested it today and some postback functions are suddenly broken. In particular, the "File Browser" one. When the user clicks on the browse button, a new window will open (a custom page) that will allow him to browse for the file, the PATH will then be passed to the parent page then saved on a textbox, then it will postback to do some validation on the path. However, on POSTBACK, the path that was stored in a textbox is now gone and was replaced by the "default" path.
Is there something that we should watch out for in migrating from 1.1 to 2.0 that can break postbacks?
Thanks! :)
This is a design issue in ASP.NET 2.0.
My textbox was set to readonly. This behaviour is by design in ASP.NET 2.0 and it has been designed with the idea that a ReadOnly TextBox shouldnt be modified in the client side by a malicious code.
Workaround:
Instead of setting the readonly property during design time, you should set in during runtime.
TextBox1.Attributes.Add("readonly", "readonly");
References:
http://www.dotnetspider.com/resources/3120-ASP-NET--TextBox-Ready-Only-losing-client-side-changes-values-across-postback.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.readonly.aspx

Resources