简体   繁体   English

ASP.NET Web窗体应用程序中的Web API重新定向到登录页面

[英]Web API in asp.net web forms application redierct to login page

In my asp.net web forms application i have added a folder at root level "WebAPI" it have a web api controller and it is authenticate by token. 在我的asp.net Web表单应用程序中,我在根级别“ WebAPI”中添加了一个文件夹,它具有Web api控制器,并且通过令牌进行身份验证。 asp.net web format application have the form authentication. asp.net Web格式的应用程序具有表单身份验证。 When i call api from rest client it redirect to login page. 当我从其他客户端调用api时,它将重定向到登录页面。

API Response:- API响应:-

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/Login/Default.aspx?      ReturnUrl=%2fapi%2fcustomer%2fGetSmsCount">here</a>.</h2>
</body></html>

Root level web.config:- 根级web.config:-

 <location path="WebAPI"> <system.web> <authorization> <allow users="?"/>
 </authorization> </system.web> </location> <system.web><authorization> 
 <deny users="?" /></authorization> </system.web>

I have given the access to anonymous on webapi folder but still it is redirecting to login page. 我已授予对webapi文件夹中的匿名用户的访问权限,但仍将其重定向到登录页面。

检查您是否给出了正确的API路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM