I'm setting up am ASP.NET MVC site onto a development server, and would like to run a wiki (Screwturn Wiki) as a subdirectory of the site. I have set up 'wiki' as a virtual directory in IIS7 (WinServer 2008), and added 'routes.IgnoreRoute("wiki");' to Global.asax,
but when I browse to that virtual directory I get a Compilation Error as it looks for Microsoft.Web.Mvc.dll, from the web.config file of my MVC site.
Am I able to completely bypass MVC for a virtual subdirectory? (I would have thought that IIS would redirect before any application layer, but I guess not).
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
It's that second line - I've tried quite a few options, but either I get no access to the wiki subdir or my ActionLinks go spastic. I could hard code all links, but that sort of defeats the purpose. I'm using MVC Preview 5 (from Codeplex) if that makes
difference.
<div>
</div><div>
</div><div>Using this in the Global.asax for the root mvc app</div><div>
</div><div>routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "time" });</div><div>
</div><div>I am still getting the 404 error, the ignore doesn't seem to be working, can any one offer advice.</div><div>
</div><div>
daggmano
Member
28 Points
23 Posts
Hosting a virtual directory under MVC
Sep 11, 2008 10:09 PM|LINK
I'm setting up am ASP.NET MVC site onto a development server, and would like to run a wiki (Screwturn Wiki) as a subdirectory of the site. I have set up 'wiki' as a virtual directory in IIS7 (WinServer 2008), and added 'routes.IgnoreRoute("wiki");' to Global.asax, but when I browse to that virtual directory I get a Compilation Error as it looks for Microsoft.Web.Mvc.dll, from the web.config file of my MVC site.
Am I able to completely bypass MVC for a virtual subdirectory? (I would have thought that IIS would redirect before any application layer, but I guess not).
Thanks in advance.
ASP.NET MVC routing iis7 Virtual Directories
maartenba
Member
368 Points
76 Posts
Re: Hosting a virtual directory under MVC
Sep 12, 2008 01:58 PM|LINK
Try to add the following configuration directives into the web.config of your /wiki/ folder:
<?xml version="1.0"?><
configuration> <system.web><
pages> <namespaces><
remove namespace="System.Web.Mvc"/> <remove namespace="System.Web.Mvc.Ajax"/><
remove namespace="Microsoft.Web.Mvc"/> <remove namespace="System.Web.Routing"/></
namespaces> </pages><
httpHandlers> <remove verb="*" path="*.mvc" /></
httpHandlers> <httpModules><
remove name="UrlRoutingModule" /> </httpModules></
system.web></
configuration>Order my book ASP.NET MVC 1.0 Quickly via http://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book
daggmano
Member
28 Points
23 Posts
Re: Hosting a virtual directory under MVC
Sep 15, 2008 01:21 AM|LINK
That did (most of) the trick - thank you. Now I'm running into another issue. In Global.asax.cs, I have added
routes.IgnoreRoute("wiki");
or a number of variations on that ("wiki*", "wiki/", etc).
This has allowed the wiki virtual subdir to be accessed, but now all the routes generated using Html.ActionLink<>() have the form
http://localhost/wiki?controller=Cont&action=Index
Somehow "wiki" has overtaken my app!!!
Any ideas as to what is going on here?
Thanks again.
maartenba
Member
368 Points
76 Posts
Re: Hosting a virtual directory under MVC
Sep 15, 2008 05:50 AM|LINK
Can you post your full route table here?
Order my book ASP.NET MVC 1.0 Quickly via http://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book
daggmano
Member
28 Points
23 Posts
Re: Hosting a virtual directory under MVC
Sep 15, 2008 06:16 AM|LINK
Sure - it's pretty complex (tongue held securely in cheek...)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("wiki/{*path}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
It's that second line - I've tried quite a few options, but either I get no access to the wiki subdir or my ActionLinks go spastic. I could hard code all links, but that sort of defeats the purpose. I'm using MVC Preview 5 (from Codeplex) if that makes difference.
maartenba
Member
368 Points
76 Posts
Re: Hosting a virtual directory under MVC
Sep 15, 2008 01:51 PM|LINK
Change:
routes.IgnoreRoute("wiki/{*path}");To:
This forces the path to be something starting with wiki/.
Order my book ASP.NET MVC 1.0 Quickly via http://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book
daggmano
Member
28 Points
23 Posts
Re: Hosting a virtual directory under MVC
Sep 15, 2008 09:43 PM|LINK
Maartenba, I owe you a beer!
Thanks for all your help.
maartenba
Member
368 Points
76 Posts
Re: Hosting a virtual directory under MVC
Sep 16, 2008 06:00 AM|LINK
Guess that beer will be warm before it arrives :-(
No problem :-)
Order my book ASP.NET MVC 1.0 Quickly via http://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book
jamie-jones
Member
4 Points
11 Posts
Re: Hosting a virtual directory under MVC
Oct 30, 2009 06:46 PM|LINK
I am having this issue. I am trying to install the time tracking starter on a virtual directory with a MVC app on the root.
I have called the virtual directory Time.
Below is the web.config from the time app
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"><?xml version="1.0"?></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"><configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <connectionStrings></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <add name="aspnet_staterKits_TimeTracker" connectionString="Server=208.78.24.53,14333;Database=databaseName;Uid=jamiejon;Password=Fia84grapu;User Instance=true" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove name="LocalSqlServer"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </connectionStrings></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <location path="Time" inheritInChildApplications="false"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <system.web></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <pages></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <namespaces></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove namespace="System.Web.Mvc"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove namespace="System.Web.Mvc.Ajax"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove namespace="Microsoft.Web.Mvc"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove namespace="System.Web.Routing"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </namespaces></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </pages></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <siteMap defaultProvider="AspNetXmlSiteMapProvider" enabled="true"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <providers></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <clear /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <add name="AspNetXmlSiteMapProvider"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> siteMapFile="web.sitemap"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> securityTrimmingEnabled="true" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </providers></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </siteMap></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <authentication mode="Forms"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <forms loginUrl="~/TimeTracker/login.aspx"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </authentication></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <compilation debug="false" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <customErrors mode="Off"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <machineKey decryptionKey="AutoGenerate,IsolateApps"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <roleManager enabled="true" ></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </roleManager></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <httpHandlers></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove verb="*" path="*.mvc" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </httpHandlers></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <httpModules></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> <remove name="UrlRoutingModule" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </httpModules></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"> </system.web></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></location></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"></configuration></div> <div></div><?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="aspnet_staterKits_TimeTracker" connectionString="*********" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
</connectionStrings>
<location path="Time" inheritInChildApplications="false">
<system.web>
<pages>
<namespaces>
<remove namespace="System.Web.Mvc"/>
<remove namespace="System.Web.Mvc.Ajax"/>
<remove namespace="Microsoft.Web.Mvc"/>
<remove namespace="System.Web.Routing"/>
</namespaces>
</pages>
<siteMap defaultProvider="AspNetXmlSiteMapProvider" enabled="true">
<providers>
<clear />
<add name="AspNetXmlSiteMapProvider"
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="web.sitemap"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
<authentication mode="Forms">
<forms loginUrl="~/TimeTracker/login.aspx"/>
</authentication>
<compilation debug="false" />
<customErrors mode="Off"/>
<machineKey decryptionKey="AutoGenerate,IsolateApps"/>
<roleManager enabled="true" >
</roleManager>
<httpHandlers>
<remove verb="*" path="*.mvc" />
</httpHandlers>
<httpModules>
<remove name="UrlRoutingModule" />
</httpModules>
</system.web>
</location>
</configuration>
<div></div><div>
</div><div>Using this in the Global.asax for the root mvc app</div><div>
</div><div>routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "time" });</div><div>
</div><div>I am still getting the 404 error, the ignore doesn't seem to be working, can any one offer advice.</div><div>
</div><div>