3

I've been using VS2012 for some years successfully for my asp.net based website but now want to upgrade to VS2015. However, the lack of the virtual path property for the development web server, shown here in VS2012, is preventing me from doing so.

enter image description here

In VS2012 I have it set to / so that static files referenced relative to the root, stylesheets, JS libraries etc. e.g.

    <link rel="stylesheet" href="/assets/template/css/template.css"></link>

can be loaded by the browser.

Without the setting in VS2015 the app compiles and runs perfectly and hyperlinks beginning / work just fine but when the browser attempts to load files referenced like that it receives error 500's (according to Fiddler) so of course none of the client side CSS, JS and some images are loaded.

Is there a solution? I've read answers to similar questions that involve editing config files in the IISExpress folder but I've not been able to find one that relates to this issue specifically.

Presumably I could work round it by adding the host name to the paths programmatically so they end up like:

<link rel="stylesheet" href="http://localhost:57209/assets/template/css/template.css"></link>

but surely there's a better solution?

Thanks for your help.

  • Is this webform or single page app? – KV Prajapati Jul 24 '15 at 08:42
  • Webform. I've just tried what I suggesed above, adding the host name, and it doesn't work either. Neither does just 'assets/template....' which is how VS2015 adds such statements when you ask it to add a stylesheet to the master page. – Huw Millington Jul 24 '15 at 08:51

2 Answers2

2

A late reaction, probably too late, but may be useful for others. I experienced the same: after opening a VS2013 project in VS2015 the stylesheets were not read. I was amazed that after removing a mimeMap from web.config all worked well. I removed:

<staticContent>
  <mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>

Found this after switching to a 64 bits version of IIS express (in Options/Projects and Solutions/Web Project). Then I got the message that the mimemap had to be removed. No idea when this mimemap has entered the web.config file.

HaWa
  • 21
  • 2
-1

You can do it from one of the page property windows for your website. I did it in 2013, but I can't remember exactly what I did. I think you open up the property pages window (by pressing Shift + f4, from the view menu, or the wrench icon on the properties window), and then go to start options.

This post has an image of the property window you are looking for. Not sure if they changed it for 2015. Is there a way to add a virtual directory to Visual Studio Development Server?

I hope this helps.

Community
  • 1
  • 1
FittyFrank
  • 124
  • 11
  • scratch that. I found an answer from the author of the book I'm learning with: http://p2p.wrox.com/book-beginning-asp-net-4-5-c-vb/89330-unable-find-virtual-path-property-vs2012.html – FittyFrank Aug 19 '15 at 00:09
  • Thank you, however VS2013 and 2015 now use IIS Express and don't offer the option to switch back to the old way of doing things so consequently the solutions you point to don't work. I worked round it by using the machine's full-blown IIS in the end. – Huw Millington Aug 20 '15 at 07:01