大佬教程收集整理的这篇文章主要介绍了URLrewrite 后不允许 AngularJS/c# WebAPI 405 方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试让 Oath2 在 AngularJs 中工作。我遇到的问题是redirectURI 中不允许有#,所以我使用HTML5 模式将其删除。
这一切似乎都正常,直到您刷新任何页面,然后找不到 404 页面。
所以我试图通过使用下面帖子中包含的 URL 重写来解决这个问题
http://www.advancesharp.com/blog/1191/angularjs-html5-mode-reloading-page-not-found-solution
我现在遇到的问题是:
request URL: http://localhost/companyname/API/public/auth/login
request Method: POST
Status Code: 405 Method Not Allowed
Remote Address: [::1]:80
Referrer Policy: Strict-origin-when-cross-origin
运行时site/API的结构是
localhost/*companyname*/
localhost/*companyname*/API
*domainname*/*companyname*/
*domainname*/*companyname*/API
我在 angularJs web.config 中的重写规则是
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouPing="MatchAll">
<add input="{requEST_filename}" matchType="Isfile" negate="true" />
<add input="{requEST_filename}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/companyname/" />
</rule>
</rules>
我已经使用以下方法在 webAPI 中包含了 cors
var corsAttr = new EnableCorsAttribute("*","*","*");
config.EnableCors(corsAttr);
如果有人能指出我正确的方向,我将不胜感激
致有类似问题的任何人。
我最终不得不编写了 2 种不同的重写规则,一种用于网站,一种用于 api
<rewrite>
<rules>
<rule name="API Rule" stopProcessing="true">
<match url="^api/(.*)" />
<action type="None" />
</rule>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{requEST_FILename}" matchType="IsFile" negate="true" />
<add input="{requEST_FILename}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/companyname/" />
</rule>
</rules>
</rewrite>
以上是大佬教程为你收集整理的URLrewrite 后不允许 AngularJS/c# WebAPI 405 方法全部内容,希望文章能够帮你解决URLrewrite 后不允许 AngularJS/c# WebAPI 405 方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。