views:

84

answers:

2

I have a website (not a web application- in visual studio you get two options-create a website/project) running on IIS 6.0. Now I want to develop few features in MVC architecture. So I created one MVC application in visual studio and everything is working fine on localhost as a separate application. Now I want to host this MVC app also inside the website I have already deployed.

I created a virtual directory(MVCDir) inside the default website in IIS 6.0. The global.asax file which was in root folder I added the routing function-

Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
    routes.Ignore("{resource}.axd/{*pathInfo}")
    routes.Ignore("{resource}.aspx/{*pathInfo}")



    routes.MapPageRoute("Default4", "{controller}/{action}/{id}", "~/MVCDir", False, New RouteValueDictionary(New With {.controller = "Home", .action = "Index", .id = Mvc.UrlParameter.Optional}))

End Sub

* NOTE- If I write routes.ignoreRoute instead of routes,ignore it says- IgnoreRoute is not a member of System.Web.RoutingCollection*

I called this routing function inside application_start function now when I run domain.com/home/index

How to solve this problem? it says resource not found

A: 

Maybe this is a problem with you child application inheriting configuration from parent. I had a similar problem when trying to put an app under a website.

You'll need to wrap <system.web> in <location> tag with inheritInChildApplications="false"

Example:

<location path="." inheritInChildApplications="false">
  <system.web>
    <!-- ... -->
  </system.web>
</location>

Here you have more detailed explanation.

Željko Živković
A: 

thanks but the problem is a bit different. in my root there is a website and inside that website I have a MVC application.

case-1)

when I run MVC application as standalone then it is the global.asax file which handles urls like domain.com/home.mvc/index with the help of function RegisterRoutes-

Shared Sub RegisterRoutes(ByVal routes As RouteCollection)

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
    routes.MapRoute( _
        "Default", _
        "{controller}.mvc/{action}/{id}", _
        New With {.controller = "Home", .action = "Index", .id =   UrlParameter.Optional} _
    )

End Sub

case-2)

I put this MVC app inside the website. Now I have two global.asax files (one in root and another inside the MVC app)  .
Now when I run domain.com/MVCDir/default.aspx- it runs fine 
When I run- domain.com/MVCDir/home.mvc/index - it should go in inner global.asax and route it accordingly - but it says resource not found . 
I think inner global file doesnt even get called. I have  tried putting below code in application_start and application_beginRequest function on inner global.asax file
    Dim app As HttpApplication = TryCast(sender, HttpApplication)
    app.Context.Response.Redirect("http://www.google.com")

It doesnt work means It is not going to inner global.asax file. 

Now what can I do to make these type of urls running- (domain.com/MVCDir/home.mvc/index)

Nishant