c# - ServiceStack api/auth/credentials 在前端迁移时返回 404
问题描述
我正在将我的前端更改为 React,因此我使用 VS2015 开始了一个新项目。我已经用我的旧 API 服务配置了 ServiceStack。一切正常,除了一个:api/auth/credentials。
当我尝试发送 POST 时收到 404。
我的Configure
有:
public MyApphost() : base("My web services", typeof(MyApphost).Assembly) {}
和:
(在之前对插件的调用中)
IoC.Container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(Dvtrck.Configuration.Manager.Current.Dsn, Dvtrck.Services.OrmLiteDialects.PostgreSQLDialectProviderLowerCase.Instance));
...(一些代码和)
Plugins.Add(new AuthFeature(() =>
new UserSession(),
new IAuthProvider[] {
new CustomAuthProvider(), // CustomAuthProvider : CredentialsAuthProvider
}));
我的 web.config 有:
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<!-- ServiceStack: Required for IIS7 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
我已经检查过类似的问题,但我的情况不同。即使我在添加时也没有错误AuthFeature
。我不明白为什么在我的旧项目中运行良好。
解决方案
您还需要配置:
SetConfig(new HostConfig { HandlerFactoryPath = "api" });
推荐阅读
- python - 在树莓派 4 上安装 OpenCV
- javascript - fetch GET request getting 400 (Bad Request)
- kubernetes - 如何创建具有特定节点池的命名空间
- flutter - Flutter 中的所有小部件都具有“bool this.mounted”属性吗?
- java - 使用 Maven 将资源中的特定属性复制到战争的 WEB-INF
- web-services - 在 Swift 5 中使用 UIGraphicsImageRenderer 为 PDF 图像着色
- python - 在python中生成截断的负二项分布
- c++ - 零规则 - 未生成默认构造函数
- android - 如何使用whenNew powermockito在android中模拟PackageInfo
- r - R:使用 dplyr 在整个数据框中查找和过滤字符串