B
B
BloodyBlade2017-04-22 12:19:20
css
BloodyBlade, 2017-04-22 12:19:20

Images are not displayed in release mode in asp.net mvc, how to fix?

Hello! I've been struggling with this problem for a long time and can't figure out what to do.
I have a project on asp.net mvc, for styles and scripts I used bundles:

public static void RegisterBundles(BundleCollection bundles)
    {
      BundleTable.EnableOptimizations = true;

      bundles.Add(new StyleBundle("~/Content/CSS/styles").Include(
        "~/Content/CSS/main.css",
        "~/Content/CSS/remodal.css",
        "~/Content/CSS/owl.carousel.css"));

      bundles.Add(new ScriptBundle("~/Scripts/app")
        .Include("~/Scripts/*.js"));

      bundles.Add(new ScriptBundle("~/Scripts/libs/app")
        .Include("~/Scripts/libs/*.js"));
    }

The web.config in compilation debug is set to false:
<system.web>
    <compilation debug="false">
      <assemblies>
        <add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
  </system.web>

At the same time, I have the following project structure:
02996d385d5c4280a6ad88ddf26aaa00.png
Inside the style files, links to images are NOT relative, they look like this: But despite all this, when the project is launched in release mode, styles and scripts are loaded, but images and fonts are not. Crashes with 404 error: Also, I can't access images through the address bar and no images are in the Source tab: I've already read dozens of posts on this topic on StackOverflow, but none of the suggested solutions help me, maybe someone was that the same problem? I would be very grateful for your help!
background: url("Images/logo.png") 0 0;
5dd9ced0dd9d4eefb4f9acfd2f18a679.PNG
1d1052b7450f43d1ba533ed305314b76.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BloodyBlade, 2017-04-26
@BloodyBlade

As a result, the problem turned out to be in these lines in web.config:

<handlers>		
      <remove name="BlockViewHandler"/>		
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>		
   </handlers>

Removed them and all was well.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question