Asp.Net MVC Bundling on the login page

I have an Asp.Net MVC site that uses forms authentication and does not have “public” access. Unauthorized requests are redirected to my login controller. In the view, I reference the css and js files through the Bundles. However, when deployed, requests for these packages are redirected to the login page with the RedirectUrl parameter. It makes sense?

So, how can I get specific packages for access without the need for authentication?

As a bad workaround, I know that I can just refer to individual files located in a shared folder, but this bypasses all the minimizing benefits.

Thanks.

+4
source share
2

, .

, , , ​​ . , ~/Content/styles, , , ~/Content/styles/css.

/css script.

-, Content , , web.config

<location path="Content"> <!--or whatever you call your bundle path instead of Content-->
  <system.web>
    <authorization>
      <allow users="*" />
    </authorization>
   </system.web>
</location>

.

+5

- :

@RenderSection("scripts", required: false)

:

@section Scripts{
//put all your scripts here
}

css.

, , , mvc , .

web.config

<configuration>
<location path="content">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>

<location path="scripts">
<system.web>
<authorization>
<allow users="?" />
</authorization>
 </system.web>
</location>

</configuration>
+1

Source: https://habr.com/ru/post/1528257/


All Articles