ASP.NET MVC Url.Content works inconsistently in HEAD tag

by martin 26. October 2010 14:13
I was trying to fix an MVC master page so that it correctly rendered urls for the referenced style sheets and JavaScript file regardless what the URL path looked like.  So I ran across this StackOverflow article which told me to use Url.Content to properly resolve my relative references from the application root (not the web server root).  So I did this.  The all of the sudden, I started getting crazy error messages saying "A potentially dangerous Request.Path value was detected from the client (<)."  It turns out that ASP.NET process things inconsistently.  After reading this post and playing around, I realized that script src URLs are treated one way and link href URLs are treated a different ways when your HEAD tag has the RunAt attribute set to Server (which it does by default).  I guess I'm surprised that there wasn't more about this anomaly out there.  I figured that there would be a lot more folks out there using MVC that wanted to put both script and link tags in their master page so that they worked regardless of the routing path in the URL.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

ASP.Net

Comments

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading



Welcome

Please contact me if you have a great idea for a project and need technical expertise in designing, developing, or integrating a custom software solution.

Recent Comments

Comment RSS