Fixing the missing virtual path property in Visual Studio 2015 - asp.net

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.
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.

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.

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.

Related

IIS Express Caching

I have a .Net project that started in Visual Studio 2008, upgraded to VS 2012 and is now in VS 2015. I'm having an issue where I update basic HTML in an ASPX page and when I refresh my browser, none of the changes are pushed across. This happens every time the project is opened and only gets the current version of the file on the first build. If I open the project, build the project, view it, any changes after this point are never displayed in the browser unless I completely close out of VS.
I did think it might be the browser but I've loaded a completely different browser (after clearing my local cache) that I hadn't used before on this machine and the page is still displaying the old information. So I feel like there is a setting somewhere in the project that got carried over from a previous version of VS that is causing the local IIS Express to not pull the latest ASPX file from the hard drive.
I tried to delete the .vs directory while VS was closed and then start it up but I had the same result.
How can I get my changes in VS be visible to IIS Express and then to whatever browser I'm using to view it?
Update: I recently updated a CSS file and those changes were immediately seen in the browser. So, it's only the ASPX files that are not updating when saved.
After some time and digging around, I found that this happened on my DEV server as well. I looked through the web.config file and this setting had some how been added to the system:
<system.web>
<httpRuntime fcnMode="Disabled" />
</system.web>
This fcnMode is a file change notification setting that communicates when a file has been updated so that the old information isn't served up again. I removed this setting entire (setting it back to the default) and it's working as expected now in all environments.
Some more info on this setting if you'd like to read the MSDN docs:
https://msdn.microsoft.com/en-us/library/system.web.configuration.fcnmode

Vaadin Valo Stylesheets

I'm having a problem using Vaadin (in Eclipse) and its associated styling engine Valo, and the TouchKit package. I mention all of these because I'm not sure which, if any, is causing the problem. The name of my custom theme (which imports Valo) is simply "touchkit".
I have the project running on a Tomcat server on localhost and accessible in my browser. I wanted to tweak some of the CSS so I edited the appropriate file WebContent/VAADIN/themes/touchkit/touchkit.scss. After editing this file, I recompile the theme and see the appropriate changes in the generated file styles.css. Then I go to load up the application in my browser, and things get weird.
I can load the page and, using Chrome's developer tools, see that the page requests styles.css for download, as expected. It gets a 200 OK response from the server, but when I view styles.css, it contains just a single \n. This is also true in Safari. Even using cURL to download styles.css yields the same result. In the Eclipse editor, and when I inspect it in the terminal, styles.css is ~12,000 lines long. Why can't my browser or cURL get that data?
I can view similar project demos on Vaadin's own site and the stylesheet (which should be almost identical to mine) is loaded correctly. Also, other Vaadin projects on my localhost server have their stylesheets loaded correctly (though they do not use Valo). Compiling the theme in Eclipse yields no errors. Because the issue presents itself across a variety of graphical and non-graphical clients, I'm starting to think the issue is with Tomcat. But I can get to the directory from which Tomcat serves files and styles.css is correct in that folder too. There's no apparent reason that Tomcat would be serving a blank file.
You may have guessed from the description, but I'm working on a Mac. Any help is appreciated!
PS Mods - I also asked this question over at Superuser since it wasn't 100% a programming question. However, I'm new at Superuser and couldn't create tags for Vaadin or Valo, so I'm asking here where there might be a better chance of getting an answer.
Hard to say, since your are doing everything fine. My best bet would be the tomcat implementation you are using, maybe there's something weird there. Try upgrading to latest if it's not or to a previous version.
FYI I'm using Tomcat 7.0.55.
PS: your attempts are in run/debug from eclipse or have you made a .war form the project and deployed it with the Tomcat-Manager?
Regards
add below to your gwt.xml, and touchkit is not valo aware see https://vaadin.com/forum/#!/thread/8264224/8264223
<set-configuration-property
name='touchkit.manifestlinker.additionalCacheRoot'
value='src/main/webapp/VAADIN/themes/MyTheme:../../../VAADIN/themes/MyTheme' />

MVC CSS not rendering in Visual Studio When debugging

I have an issue where the CSS is not rendering properly when I compile the MVC project and view it on [https://localhost/MyApp.] The buttons, and background image are not showing up. It worked one time, then for some reason it stop working. Something with the pages not caching? I used firebug to check to see if the pages were missing, and no errors were found. Something in Visual Studio 2010 settings need changing or IIS?
However, when I publish it to an individual website, instead of in the (default web site) area, using [https://localhost:444] website I setup in IIS 7.5, the css seem to render fine.
What is the problem?
One common problem that occurs on MVC 4 websites is difference between release and debug when you have css bundles. It does not have to be your case, but you have the symptoms.
I will explain on an example.
If you have bundle which looks like this:
var styles = new StyleBundle("~/Content/css").Include(
"~/Content/toastr.css",
"~/Content/flags/stylesheets/flags16.css",
"~/Content/flags/stylesheets/flags32.css",
"~/Content/Site.css")
And in flags16.css you have:
background:url('flags/images/flags16.png');
Which uses file in ~Content/flags/images/flags16.png
That will work in release mode (compilation debug="false" in web.config), because all of your css files in bundle will be served as 1 file located at ~/Content/css with relative path 'flags/images/flags16.png' pointing at correct file.
However, in debug mode, ASP.NET MVC will disable minification, and if you used #Styles.Render("~/Content/css") inside your view, it will render link to every one of your files contained in a bundle, so there will be a:
<link href="/WorkOrders.Web/Content/flags/stylesheets/flags16.css" rel="stylesheet">
And from that path, relative path to image is not ok, so images in flags16.png will not be rendered.
One way to solve this, you need to move your .css file which contains references to images to the location where bundle is pointing (~/Content in this case), so it will have same path when it is served minified and raw.
UPDATE As your app is not mvc4, and you have problems when your app is not in the root of your web site (i.e. when it is in localhost/myapp) then you need to check paths in references to your pictures. It is possible that you referenced them absolutely ('/somepath/mypic.png'), and when your app is in localhost/MyApp, path needs to be localhost/MyApp/somepath/mypic.png. You can solve that by replacing path with #Url.Content(~/somepath/mypic.png), if you are using it from cshtml. If path is in css, then you need to put relative path to your pictures.
I have just been battling with the same problem - images, scripts and css not being found or rendered. (Visual Studio 2013, Windows 8.1. Project moved across from Visual Studio 2010.)
The problem was caused by a line in Web.config:
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
It seems that because the IIS Express application.host file already contained this mimeMap definition, IIS Express couldn't cope with it being defined again.
Removing this line from Web.config completely solved the problem.
It looks like your web site is configured to use SSL. Except that when running locally you probably do not have a valid SSL certificate which is trusted by a certification authority and the client browser is refusing to download the static resources. One way to fix that is to add the address as trusted. So copy paste the url to some of your CSS files in your browser address bar:
https://localhost/MyApp/Content/Main.css
and you will see a warning about the invalid certificate that you could ignore by adding an exception to your browser. Hit Ctrl+F5 to force a refresh once the exception is added and your application should start working properly.
When I had this problem I found that all of my CSS and Script files were encountering a HTTP 500 error when they were being downloaded in the browser (Firefox 33.0.2).
Killing the instance of my browser in the Task Manager and then starting afresh fixed the issue for me.

CSSFriendly issue just after publishing to web server

I created a website and used css friendly adapters for Menu, TreeView and GridView, all was correct, but after publishing it to my great web server, the menus and treeviews didn't load and there is just some bullets!
Here is my work: http://jds.cot.ir (dead link)
Left side I have a menu which did not load.
Did you copy over the App_Browsers folder? I'd check you copied all files over and, if you can, restart the application pool (touching web.config should achieve this).
I found the problem and the solution, I have an error loading one css file:
<link href="/WebResource.axd?d=FmPs0x8PbK0cHdhnI4N-J7cB33HdEr5UOoA_QzdIwqZdeINM8Kod5dxru5SzZMkL0&t=633820044382031250" type="text/css" rel="stylesheet" />
and the content of this css was an error titled:
Specified argument was out of the range of valid values. Parameter name: utcDate
I changed my pc date to one month ago and rebuilt my solution, and upload it again.
And every thing is correct. ;)
Try deleting precompiled.config from the root of the web app on the server. That did it for me. Haven't really looked into what the pros and cons are. Looks like the publisher's precompilation doesn't take into account the control adapters for some reason. I just ran into this in VS2010 beta 2.

CSS file not getting downloaded in Visual Studio 2008 SP?

This might sound a little wierd, but all of a sudden the CSS and Javascript files referenced in my master page are not being downloaded while the page is being rendered. I am working on a ASP.NET MVC project and things were all fine like half an hour ago!
Here is what I have in head section of the master page,
<link href="/Content/MyCSS.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
I can see the CSS class intellisense while designing pages. But in the page source I do not see these files being added. I can see the css being applied in the VS designer. I have tried restarting VS, restarting my machine too.
Anyone else faced this situation before. I might go crazy now.
Sounds odd. I would use Microsoft Fiddler to see if that gives you any clues. Also are you using IIS or the built in Web server?
If you are using some kind of source control, you might also want to review your recent changes.
Check that your paths are correct. You can create a web app in a virtual directory off the root, so you path would be "/myapp/default.aspx", in which case your paths for your css and js would be wrong.
Try to avoid putting absolute paths in file references.
You may want to try and remove the leading slash, for example.

Resources