Request.RawURL未设置为Default.aspx的在应用程序根目录 [英] Request.RawURL not set to default.aspx at application root

查看:415
本文介绍了Request.RawURL未设置为Default.aspx的在应用程序根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级我的ASP.NET应用程序从.NET 3.5至4.0,并发现Request.RawURL设置为/请求的默认文档,Default.aspx的,通过的 http://mysite.com/ 。在.NET 3.5中,Request.RawURL将被设置为/default.aspx。

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".

有没有什么办法,使在4.0这个.NET 3.5的行为?

Is there any way to enable this .NET 3.5 behavior in 4.0?

我曾尝试通过注册表禁用无扩展名的URL。我也经历了 ASP.NET 4.0中的重大更改的doc和有设置表单标签action属性,但查看页面的源代码显示,对于action属性设置的值不被拾起并回复到/".

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 "/".

目前在IIS 7.5集成模式和Win7运行。

Currently running on IIS 7.5 integrated mode and Win7.

推荐答案

事实上,我可以与.NET 2.0和.NET 4.0切换时重现问题 - .NET 2.0安培; 3.5双方共享相同的公共语言运行时CLR2,与增加的基类库(BCL)的较高版本的.NET。随着.NET 4.0 CLR4来了,而且似乎是区别在哪里发生。我以前从没注意到!

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!

我相信新的行为是正确的,因为 RawUrl 反映实际请求的URL路径。这是很难理解您的具体需要,但我想你可以尝试使用 Request的代替。

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?

这篇关于Request.RawURL未设置为Default.aspx的在应用程序根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆