10
我们正在构建将使用基本身份验证的ServiceStack API。我目前正在建立权威性在我APPHOST如下:当ServiceStack身份验证失败时,请不要重定向?
var authDb = new OrmLiteConnectionFactory("Server=(...);", true, MySqlDialectProvider.Instance);
var authRepo = new OrmLiteAuthRepository(authDb);
authRepo.CreateMissingTables();
container.Register<ICacheClient>(c => new MemoryCacheClient());
container.Register<IUserAuthRepository>(c => authRepo);
Plugins.Add(
new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider() })
);
在做,没有授权头或错误的用户名+通过响应的请求被重定向到/Account/Login.aspx?ReturnUrl= ...
Parital请求响应+例如:
POST http://localhost:60278/reserve HTTP/1.1
HTTP/1.1 302 Found
Location: /Account/Login.aspx?ReturnUrl=%2freserve
X-Powered-By: ServiceStack/3,924 Win32NT/.NET
有没有一种方法,使之401未授权或HTTP 403禁止只用HTTP响应?
我认为必须有一些ASP.net的东西在这里混淆了我。我在文档中看到它,并尝试了HtmlRedirect = null,并且我使用application/json作为Accept/Content-type标头。重定向与您写入(〜/ login)不同,但是/Account/Login.aspx。我会通过我的global.aspx和东西,让你知道。 我现在接受你的回答,不过,这是SS正确设置时的解决方案。谢谢! :) – Magge
是的,这是我的不好。我的Web.config中仍然有.net成员身份,似乎覆盖了SS身份验证。我删除它之后就像一个魅力。 – Magge
我懂了! ... :) –