views:

75

answers:

3

When running my web app on my local machine i can ref css/scripts/images using:

<link href="/Content/Site.css" rel="stylesheet" type="text/css" />

But when I deployed to my Development server, it wasn't able to find any of my content. After researching the issue everyone suggests using the below method:

<link href="<%=Url.Content("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />
<img src="<%=Url.Content("~/Content/3.png")%>" />

At least now all my content is loaded and works when I push to the development server. However now that I have the server script in there, the "Design" view in Visual Studio doesn't load any styling/etc. I'm wondering if there is an alternative or something I'm missing that perhaps would fix this? Or maybe I'm going about it all wrong? Any input is greatly appreciated.

+5  A: 

The suggestion you found is a great way to reference content.

As far as Design View goes, don't sacrifice the elegance of your code just to get Design View. Learn to love Code View. Preview in a browser. In my experience, that workflow really has no major downsides (once you get used to it).

(As an aside, I think most of the developers who like ASP.NET MVC do not use "Design View" in Visual Studio. One of the reasons I love MVC is that it allows me to be picky about the markup. Any kind of designer lies outside that kind of thinking.)

Larsenal
Agreed. I never use the Design View in ASP.NET MVC.
Robert Harvey
I never use Design View period.
JohnB
+4  A: 

You can always cheat the designer with an atrocity similar to this:

<% if (false) { %>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<% } %>
<link href="<%=Url.Content("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />

but hey, quite honestly hitting F5 in the browser will give you faster results than waiting for the designer to load (even if your application is hosted on the other end of the world).

Darin Dimitrov
That's a high price to pay for design view. Browser refresh is definitely the way to go.
Larsenal
@Larsenal, completely agree. While in the classic WebForms world, a designer could be useful, in the ASP.NET MVC world there's no sane justification for its usage.
Darin Dimitrov
+1 for hitting F5
Gabe Moothart
Ctrl-F5 is even faster ;-)
queen3
+1 for the <kbd>F5</kbd> button! How did you do that?
JohnB
+1  A: 

Design view is broken? Thats not a bug in your code, thats just the way it is. This is true for ASP.NET MVC and regular ASP.NET

Frank Schwieterman