3

This is a similar question to "How To Disable ASP.NET MVC Url routing" which hasn't been answered (I don't think the responders understood why it was needed).

I have an existing application that uses AngularJS and MVC url routing to serve the templates. I want to remove the MVC url routing as it is redundant (see comment below. we are using webApi to return data via ajax so the views/controllers are not needed).

I have removed the call to RegisterRoutes in the Global.asax.cs. There doesn't seem to be anything in the Web.config apart from a reference to System.Web.Routing so I left it.

I am using IIS Express with Visual Studio 2012.

When the application runs I get a 403.14 Forbidden error. I have enabled directory browsing. I have set the start page in the project in Visual Studio but I get a 404 despite the file definitely being there.

I have tried creating a non-mvc website and copying the contents of the web.config to my application, but this didn't work.

2 Answers 2

0

if you mean by removing the .aspx on the end (www.something/home.aspx); In C#, instead of using

response.redirect("~/home.aspx");

use

server.transfer("~/home.aspx");
Sign up to request clarification or add additional context in comments.

1 Comment

I'm using AngularJS which has it's own routing mechanism. I just want my existing application to behave like a normal asp.net (non-mvc) website without routing (i.e. localhost/index.html will serve the index.html page)
0

AngularJs routing has nothing to do with ASP.Net MVC Routing.

Angular Routing:

Is used for deep-linking URLs to controllers and views (HTML partials). It watches $location.url() and tries to map the path to an existing route definition.

ASP.Net MVC Routing:

ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.

In essence, AngularJs routing deals with client-side routing (using the location Url), whilst ASP.Net MVC deals with mapping http Urls to the appropriate controller/action in the server-side.

1 Comment

Yes I know. For example, in the routing config for an Angular module we have "templateUrl: 'Customer/edit'". Normally, this would be a static file, e.g. "templateUrl: 'CustomerEdit.html'". At the moment we have an MVC CustomerController that returns a partialview. I want to remove this as it is redundant. Basically, I want a project that was created as an MVC ASP.NET website to convert back into a regular ASP.NET website. I don't want to recreate the entire project from scratch. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.