c# - Using images on Web Applications and Visual Studio for ASP.NET MVC -


I am developing an ASP.NET MVC application with MS Visual Studio 2008 SP1.

My project structure is default:

project | -Source | -CSS | -img | -Modals | -Specialty | Controllers

This is the thing that I am able to use all the content placed under the Content directory, this file contains Is included. On the other hand, if I have an image (IE is a user uploaded image) that is on the correct physical directory (Project \ Material \ img) but not included in the project, then I'm getting 404 < / Strong> Error when I access them from the browser

I think my URL is correct:

and I project \ content \ img \ my_image.jpg

Is there a file under what could be wrong? Do I have to include all the files on this project? I do not think so, because this would mean that I can not have images uploaded and saved by web users like this.

Thank you very much.

If you are hosting your project with IIS 7, then you should see the IIS 7 (handler mapping ) To add that content-type. But if you are hosting your project with ASP.NET Developer Server, then it is not necessary.

Using the following code in the web.config file

  & lt; Configuration & gt; & Lt; System.webServer & gt; & Lt; Operators & gt; & Lt; Add name = "css mapping" path = "* .css" verb = "*" type = "System.Web.StaticFileHandler" resource type = "unspecified" preCondition = "integrated mode" /> & Lt; Add name = "js mapping" path = "* .js" verb = "*" type = "system web. Static file handler" resource type = "unspecified" precondition = "integrated mode" /> & Lt; Add name = "gif mapping" path = "* .gif" verb = "*" type = "System.Web.StaticFileHandler" resource type = "unspecified" preCondition = "IntegratedMode" /> & Lt; Add name = "jpg mapping" path = "* .jpg" verb = "*" type = "System.Web.StaticFileHandler" resource type = "unspecified" precondition = "integratedMode" /> & Lt; Add name = "png mapping" path = "* .png" verb = "*" type = "System.Web.StaticFileHandler" resource type = "unspecified" preCondition = "integratedMode" /> & Lt; / Operators & gt; & Lt; /system.webServer> & Lt; / Configuration & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -