0

I'm using ASP.Net MVC, my bundles looks something like:

        bundles.Add(new Bundle("~/bundles/rgmpjsbundle").Include(
            "~/Scripts/jquery-{version}.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/Scripts/jquery.unobtrusive*",
            "~/Scripts/jquery.validate*",
            "~/Scripts/modernizr-*",
            "~/Scripts/jquery.address-1.5.js",
            "~/Scripts/tabmenu.js",
            "~/Scripts/knockout-2.2.0.js",
            "~/Scripts/knockout.mapping-latest.js",
            "~/Scripts/jquery-ui-1.10.3.custom.js",
            "~/Scripts/KnockoutCustomBindings.js",
            "~/Scripts/knockout-sortable*",
            "~/Scripts/moment.js"));

This is pretty standard. the problem comes when I go to deploy my application, in the Development region. IIS is set up like the following (I know it's not great):

DEVWEBSITE
   ->  app 1
   ->  app 2
   ->  app 3
UATWEBSITE
   ->  app 1
   ->  app 2
   ->  app 3

However; production is set up differently in that each application has it's own web site. This is proving to be a right pain in my butt as under the DEV/UAT structure my application will jump all the way back to the DEV/UAT website (Shell site) with the ~ but in the PROD environment it will up back to the root of the web application. I would use relative referencing except I'm using MVC URL rewrites.

Does anyone have a solution to this problem? Maybe some setting on IIS7 to catch ~ references?

Josh
  • 79
  • 1
  • 8

1 Answers1

0

You can try to create a helper like @html.getMyPath() and a key in your web config with differents configuration for environments (dev,UAT Production) the key should contain something like key="pathToFolder" value="/" or "~/" and then load that configuration in cache in your app initiation.

The helper will read the parameter and find a resolution to the path of the files.

other solution could be that for each environment you can set different "root locations" and use server.mappath to determinate the physical location of the files for each environment this implementation should be inside a html helper as well.

I hope that helps

Community
  • 1
  • 1
pedrommuller
  • 15,741
  • 10
  • 76
  • 126