asp.net mvc - Stopping MVC ViewMasterPage from resolving CSS URLs -


by default master pages in .net mvc2 placed /folderlevel1/folderlevel2/site.master accessed url domain.com/urllevel1/urllevel2/ resolve url in tag:

<link href="/content/site.css" rel="stylesheet" type="text/css" /> 

to

<link href="../../content/site.css" rel="stylesheet" type="text/css" /> 

this becomes problematic in multi-tennant mvc app. , want stop behaviour. want master page leave url alone.

you having issue because asp.net performs magic tricks when specify head tag server side control so:

<head runat="server"> 

these tricks include:

  • resolving relative css paths
  • populating title , meta tags view's @page directive

if don't want these tricks, remove runat attribute head tag:

<%@ master language="c#" inherits="system.web.mvc.viewmasterpage" %>  <!doctype html> <html> <head>      <link href="content/site.css" rel="stylesheet" type="text/css" /> </head> <body> ... </body> </html> 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -