如何在MVC5应用程序中停止MVC路由并仅允许角度路由? [英] How to stop MVC routing and allow only angular routing in MVC5 application?

查看:71
本文介绍了如何在MVC5应用程序中停止MVC路由并仅允许角度路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究MVC5应用程序。

我必须将Angular路由应用到它并且能够应用它。

但是在任何回发上应用程序都会返回再次进入MVC路由。

当我们打算在MVC应用程序中使用角度路由时,请建议如何停止MVC路由?



For例如:我有一组用于表格的脚手架页面来执行CRUD操作。

要应用Angular路由,看起来要使视图的布局为空。

所以在保存按钮上单击创建或编辑,数据将被保存,但由于其回发,路由将从角度更改为mvc,页面将显示布局,这意味着它将进行mvc路由。

请建议。

I am working on a MVC5 application.
I have to apply Angular routing to it and am able to apply that.
But on any postback the application goes back to the MVC routing again.
Please suggest how to stop MVC routing when we intend to use angular routing in a MVC application?

For ex : I have a set of scaffold pages for a table to perform CRUD operations.
To apply Angular routing it seems the Layout of the views to be made null.
So on a save button click in Create or Edit, the data gets saved but because of its postback, the routing changes from angular to mvc and the page gets displayed with out a layout which means it is going to mvc routing.
Please suggest.

推荐答案

我们在这里遇到了同样的问题,不得不使用html5Mode将其关闭并使用散列路由。这似乎解决了MVC和Angular路由的问题



We had the same issue here and had to use the html5Mode to turn it off and use hash routing instead. This seems to solve our issue with the MVC and Angular routing


location.html5Mode ( false );
location.html5Mode ( false ) ;


删除Global.asax文件中设置的路由。



但是,这不应该需要。来自angular和mvc的路由可以一起存在。

它调用视图(角度和MVC)的方式和位置。
Remove the routes set in the Global.asax file.

However, this should not be required. Both routing from angular and mvc can exist together.
Its how and where you call views (angular and MVC) that will matter.


这篇关于如何在MVC5应用程序中停止MVC路由并仅允许角度路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆