SEO重定向问题 [英] SEO redirect problem

查看:124
本文介绍了SEO重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我为我的webmatrix网站运行优化报告时,我收到多个问题:

该页面包含不必要的重定向。这是导致问题的代码段:

When I run optimization report for my webmatrix website, I get multiple issues stating:
"the page contains unnecessary redirects". This is the code snippet that causes the problem:

if(!WebSecurity.IsAuthenticated)
   {
      //navigate to login page
       Response.Redirect(App.PathUserLogin + "?returnUrl=" + Request.Url.LocalPath);
   }



在使用某些页面之前,用户必须登录并且上面的代码试图将他/她重定向到登录页面(如果他没有登录)。那么为什么它被检测为不必要的,我该如何解决这个问题?


Before using some pages the user has to log in and the above code is trying to redirect him/her to the login page (if he is not logged in). So why is it detected as unnecessary and how can I fix this?

推荐答案

也许可以帮助使用这种方法在本教程中 [ ^ ]:

- 创建一个子文件夹(例如会员);

- 将要保护的文件放入此子文件夹;

- 在 Members 子文件夹中,创建名为 _PageStart.cshtml 的文件。当请求子文件夹中的任何页面时,此页面首先运行;

- 在 _PageStart.cshtml 文件中,调用 WebSecurity.IsAuthenticated 来确定用户是否已登录。如果不是,请将其重定向到登录页面。
Maybe could help the approach used in this tutorial[^]:
- create a subfolder (e.g. Members);
- put files you want to protect into this subfolder;
- in the Members subfolder, create a file named _PageStart.cshtml. When any page in the subfolder is requested, this page runs first;
- in the _PageStart.cshtml file, call WebSecurity.IsAuthenticated to determine whether the user is logged in. If they are not, redirect them to the login page.


这篇关于SEO重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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