Showing posts with label iis-express. Show all posts
Showing posts with label iis-express. Show all posts

Wednesday, January 25, 2017

Cannot display .svg files in Visual Studio 2012 (IIS Express)

Leave a Comment

Im trying to display .svg files in my web application using Visual Studio 2012, IIS Express v8.0 and ASP .NET Web Forms.

Things i already tried:

  1. Adding .svg extension to web.config
<staticContent>   <remove fileExtension=".svg" />   <mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> </staticContent> 
  1. Adding .svg extension to C:\Users\UserName\Documents\IISExpress\config\applicationhost.config
<staticContent lockAttributes="isDocFooterFileName">   ...   <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />   ... 
  1. Copy the URL of the image to the browser, and it's displaying fine.

enter image description here 4. Publish the site under IIS, and it's displaying fine. Also, we have a developer using Visual Studio 2013 and it's displaying fine using IIS Express v8.5.

Im adding the .svg as icons, using a span element with a class that has as background with url of the file, so i can't use this solution: SVG files in VS2012

This is the style of class added to the span:

background: transparent url(images/svg/reports.svg) no-repeat scroll 0px 0px; 

What's happening?

1 Answers

Answers 1

Based con @user1429080 suggestion, there's a workaround (altought is not the cleanest way it works):

My workaround for this was to create my own httphandler locally which overwrote the content-type for svg.

public class SvgHandler : IHttpHandler {      public bool IsReusable     {         get { return false; }     }      public void ProcessRequest(HttpContext context)     {         context.Response.ContentType = "image/svg+xml";         context.Response.BinaryWrite(File.ReadAllBytes(context.Request.PhysicalPath));         context.Response.End();     } } 

and in web.config i added:

<httpHandlers>   <add verb="*" path="*.svg" type="SvgHandler" /> </httpHandlers> 

with this solution you don't have to use IIS express, you can just use the regular development server in visual studio 2010

Source: Visual Studio Not Displaying SVG image as background

Read More

Wednesday, April 13, 2016

How to leave iisexpress running after stopping debugging in Visual Studio 2015 Update 2?

Leave a Comment

Previously this could be done by unchecking "Enable Edit and Continue" under (Project) Properties | Web | Debuggers. This checkbox is not there in Visual Studio 2015 Update 2. The same checkbox including four sub-options can be found in Options | Debugging | General, but unchecking this no longer resolves the issue.

3 Answers

Answers 1

Same problem here.

My workaround for now is to add "Detach all" shortcut on the toolbar instead of the "stop" button.

Answers 2

Not a fantastic answer, but a workaround.

  1. Select your Web App in Solution Explorer, then press F4 to see the properties pane. In there, ensure 'Always Start When Debugging' is set to true.
  2. If you have another IIS Express Web App in the same solution, do the same for that.
  3. If you don't have another IIS Express Web App then create a minimal .Net web app without any code using the File New templates and set 'Always Start When Debugging' to true for that too.
  4. Here is the trick, right click on the Web App project in Solution Explorer that you don't want to leave running (the one in step 2 or 3) and select 'Set as StartUp Project'.
  5. Run your solution as usual, you'll get both of your Web Apps running. When you exit, it only detaches and halts the startup project which leaves your main app running.

Obviously a bug if they can leave the other Web App running. But at least this workaround will make debugging a little easier.

Answers 3

Maybe this is not the answer to the OP question, but I use the "view in browser" option to achieve this.

Read More