匿名ユーザーのアクセスを(自分のウェブサイトのルートにある)ミュージックフォルダに制限します。またMVC、ブラウザのリターンエラー:ウェブサイトのリダイレクト回数が多いweb.configファイルで特定の制限付きフォルダのファイルを閲覧したとき
<allow users="*" />
<deny users="?" />
のweb.configファイル:私はあまりにも、このいずれかをテストし
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>
:それから私はMusic
フォルダにweb.configファイルにファイルをこのコードを置きますのウェブサイトは、怒っている設定:
<authentication mode="Forms">
<forms loginUrl="~/account/login" timeout="2880" />
</authentication>
<modules runAllManagedModulesForAllRequests="false">
<remove name="FormsAuthenticationModule" />
<add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" />
<remove name="UrlAuthorization" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
</modules>
<rule name="Redirect to https" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:0}" appendQueryString="false" redirectType="Permanent" />
</rule>
<location path="~/Music">
<system.webServer>
<handlers accessPolicy="Read" />
</system.webServer>
</location>
そして、このコードは、startup.csの一部です:私はexample.com/music/1.mp3
を参照し、それは/account/login
に私を戻しますが、私がログインしたとき、それは私から、次のエラーを表示したときに、今
var loginPath= new UrlHelper(HttpContext.Current.Request.RequestContext).Action(MVC.Account.Login());
appBuilder.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString(loginPath),
// Other Codes
}
ブラウザ:
WebsiteName redirected you too many times.
net::ERR_TOO_MANY_REDIRECTS
私はnone
に認証モードを変更した場合も、それは(私はそれを文句を言わないこと!)私にそれのようなプロンプトを表示:
Note1: I cleared the browser cookies but no success.
- リダイレクトループの理由は何ですか?
- リダイレクトループなしでこの作業をどのように安全に行う必要がありますか?
更新:
私のプロジェクトは、ログインページのURLメカニズムへリターンを持っています。だから私が/Music/1.mp3
をブラウズすると/account/login?ReturnUrl=/Music/1.mp3
にリダイレクトされ、ログイン後にこのメカニズムが自動的に/Music/1.mp3
にリダイレクトされます。私はこのステップで私は再び/Music/1.mp3
を開くためのアクセス許可が不十分だと思います!そして私は再度ログインページにリダイレクトされ、ERR_T_OOMANY_REDIRECTS
エラーが出るまでこのループが続きます。
はい、質問は次のとおりです。音楽フォルダにログインしているユーザーを拒否する理由は何ですか?音楽フォルダに関するweb.configファイルには場所の設定はありません。 – RAM