首页 新闻 会员 周边

mvc跳转问题

0
悬赏园豆:10 [已解决问题] 解决于 2016-08-04 19:37

 正常地址是http://xxxx/OA/pms/

但是之前有部分用户保存的是 http://xxxx/oa/pms/ 小写 或者不小心输入小写。

希望能自动跳转到http://xxxx/OA/pms/ 页面 

请问怎么解决呢?

目前这个是跳转的控制器 没测试 感觉有问题。 OA/pms/是iis发布设置的虚拟目录。

 

namespace pms.AOP
{
    public class LoginCheckAttribute : Controller
    {
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.RouteData.Values["controller"].ToString().IndexOf("Login", StringComparison.Ordinal) >= 0)
            {
                //oa/pms/跳转
                if (filterContext.HttpContext.Request.Url != null && filterContext.HttpContext.Request.Url.ToString().IndexOf("oa/pms", StringComparison.Ordinal)>=0)
                {
                    filterContext.Result = RedirectToRoute(new { Controller = "Login", Action = "Index" });
                }
                return;
            }

            var token = "";
            var httpContext = System.Web.HttpContext.Current;
            if (httpContext.Request.Cookies["token"] != null) token = httpContext.Request.Cookies["token"].Value;
            if (token == "")
            {
                var httpCookie = httpContext.Request.Cookies["Redis_SessionId"];
                if (httpCookie != null)
                    token = "Session_" + httpCookie.Value;//第3方登入
            }
            var flag = RedisBase.Hash_Exist<object>(token, "userName");
            if (flag) return;
            filterContext.Result = RedirectToRoute(new  { Controller = "Login",  Action = "Index", flag = "expired"  });
            base.OnActionExecuting(filterContext);
        }
    }
}
s_p的主页 s_p | 初学一级 | 园豆:138
提问于:2016-08-04 16:11
< >
分享
最佳答案
0

首先,IIS发布默认是不区分大小写的。另外,作为虚拟目录,浏览器会当成两个来存储localStorage么(还真没注意过这个问题)?

就问题本身来说,在页面index.html上,写个js,发现是小写的oa,就重新设定一个新的跳转地址。(该方式也可以在后端通过Navigate来做)。

 

收获园豆:10
幻天芒 | 高人七级 |园豆:37175 | 2016-08-04 17:14

这个方法好。在页面index.html上,,写个js,发现是小写的oa,就重新设定一个新的跳转地址。明白了

s_p | 园豆:138 (初学一级) | 2016-08-04 18:39
其他回答(1)
-1

你找找有没有类似“MVCURL忽略大小写”这样的结果吧。

顾晓北 | 园豆:10844 (专家六级) | 2016-08-04 16:18

其实大小写结果一样 只是我页面保存了cookie  和 localstorage 登入成功后变成http://xxxx/OA/pms/

之前写入的都在 http://xxxx/oa/pms/这里域里面 所以会出现一个异常问题 提示未登入。

支持(0) 反对(0) s_p | 园豆:138 (初学一级) | 2016-08-04 16:20

@s_p: 是你的cookie设置问题?你的cookie设置的path是什么?

支持(0) 反对(0) 顾晓北 | 园豆:10844 (专家六级) | 2016-08-04 16:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册