【发布时间】:2021-07-28 07:40:09
【问题描述】:
我正在尝试让 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
运行站点/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);
如果有人能指出我正确的方向,将不胜感激
【问题讨论】:
标签: c# angularjs asp.net-web-api url-rewriting cors