asp.net – 从global.asax – mvc重定向到一个动作
发布时间:2020-12-16 00:40:20 所属栏目:asp.Net 来源:网络整理
导读:在我的Web应用程序中,我正在验证来自glabal.asax的url。我想验证网址,如果需要,需要重定向到一个操作。我正在使用Application_BeginRequest来捕获请求事件。 protected void Application_BeginRequest(object sender,EventArgs e) { // If the product is
在我的Web应用程序中,我正在验证来自glabal.asax的url。我想验证网址,如果需要,需要重定向到一个操作。我正在使用Application_BeginRequest来捕获请求事件。
protected void Application_BeginRequest(object sender,EventArgs e) { // If the product is not registered then // redirect the user to product registraion page. if (Application[ApplicationVarInfo.ProductNotRegistered] != null) { //HOW TO REDIRECT TO ACTION (action=register,controller=product) } } 或者有任何其他方法来验证每个url,同时在mvc中获取请求,并在需要时重定向到一个操作 解决方法
使用以下代码进行重定向
Response.RedirectToRoute("Default"); “默认”是路由名称。如果要重定向到任何操作,只需创建路由并使用该路由名称。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 使用ASP.NET MVC导出数据到Excel文件4 C#正
- 会话处理在asp.net
- kendo-asp.net-mvc – 在Kendo Scheduler自定义模板中绑定D
- ASP.net用户数据在访问对象的用户之间进行交叉
- 什么是部署ASP.Net Web应用程序的好方法?
- asp.net-mvc-4 – 附加到HTTP响应的CORS标头未发送到浏览器
- asp.net-mvc – mvc 4 beginform with route name
- asp.net – 此行已经属于另一个表
- asp.net-mvc – 我需要在我的所有页面上使用`[ValidateAnti
- asp.net – 在IIS7.5中什么模块删除了400个错误请求的正文
推荐文章
站长推荐
- asp.net – 如何使用httpErrors添加默认错误页面
- asp.net – 在ObjectDataSource更新事件期间取消
- ASP.NET MVC和IE缓存 – 操作响应头无效
- asp.net-mvc-3 – 在Dbcontext中的.NET MVC 3回滚
- asp-classic – ConnectionTimeout无效
- asp.net – 检查控制启动的AJAX请求
- 在后面的asp.net代码中使用web服务的最佳方法
- asp.net-mvc – 如何利用Resharper的“导航到控制
- asp.net – 如何更改FileUpload控件(System.Web.
- asp.net-mvc-2 – ASP.NET MVC 2和PRG模式
热点阅读