【发布时间】:2021-04-05 07:58:56
【问题描述】:
在开发阶段,quasar项目可以在IIS虚拟应用下托管和运行。发布时,从dist文件夹复制文件到iis根目录,index页面正常显示,但是使用webapi url发起httppost请求时出现403错误。我使用了 IIS UrlRewrite 组件。似乎与 webapi 请求相关的问题与 urlrewrite 冲突。
- web.config 文件包含 url 重写规则
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" 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="index.html" />
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
- startup.cs 文件包含控制器路由模式
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseSpaStaticFiles();
app.UseAuthorization()
.UseCors("AllowAll");
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllerRoute(
name: "default",
pattern: "api/{controller=Home}/{action=Index}/{id?}");
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseVueCli(npmScript: "serve", forceKill: true);
}
});
}
- IIS 403 错误 当有 webapi 请求时,就会发生错误...
http://localhost/webdemo2/api/wf/QueryProcessRoles
有一篇文章对将quasar项目部署到IIS很有用,但是403错误仍然存在。有人可以在这里找到解决方案吗?谢谢
https://forum.quasar-framework.org/topic/3004/deploy-quasar-application-in-iis
【问题讨论】:
标签: vue.js asp.net-core webapi quasar