加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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");

“默认”是路由名称。如果要重定向到任何操作,只需创建路由并使用该路由名称。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读