简体   繁体   English

IIS7向URL添加乱码,导致404 CSS文件

[英]IIS7 adds gibberish to URL, causes 404 for CSS files

I have a C# web application that runs fine when hosted by VisualStudio. 我有一个C#Web应用程序,在由VisualStudio托管时运行良好。

When I host it on IIS, the link to my CSS stylesheet returns a 404 error. 当我将其托管在IIS上时,指向我的CSS样式表的链接返回404错误。

Basically: 基本上:

http://hostname/Sitename/default.aspx

becomes

http://hostname/Sitename/(S(ubd3fhzfs04ebb1qzfsjlsse))/default.aspx

I dont know what might've changed, but this started happening after a publish a couple of weeks ago. 我不知道可能会发生什么变化,但这是在几周前发布后开始发生的。

I have tried deleting the site folder and re-publishing. 我尝试删除站点文件夹并重新发布。

I have 2 other applicatins hosted that are also published via VS, and their URLS are normal ie 我还托管了2个其他applicatins,它们也通过VS发布,它们的URL正常,即

http://hostname/Sitename/default.aspx

From what I can tell, the web.configs and IIS setups are the same for all sites. 据我所知,所有站点的web.configs和IIS设置都是相同的。

That URL contains a session cookie ID, it is caused by a cookieless session (either cookies are disabled and automatic detection kicks in, or you explicitly set up cookieless sessions, or it is caused by a device-specific ASP.NET configuration). 该URL包含会话cookie ID,它是由无cookie会话引起的(禁用cookie并启动自动检测,或者您明确设置了无cookie会话,或者由特定于设备的ASP.NET配置引起)。 It can simply be fixed by changing session settings. 只需更改会话设置即可解决此问题。 However, I would also fix my static file references to be relative instead of absolute, so they wouldn't cause 404 errors in different setups. 但是,我也将我的静态文件引用固定为相对的而不是绝对的,因此它们不会在不同的设置中导致404错误。 Cookieless URL's are handled transparently by ASP.NET, so they don't cause 404 errors on their own, only if you have hard-coded absolute URL's, which is bad practice anyway. 无Cookie的URL由ASP.NET透明处理,因此只有在您对绝对URL进行了硬编码的情况下,它们才不会自己导致404错误,这仍然是一种不好的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM