我有一个ASP.NET 4应用程序,我在我的SharePoint站点的虚拟目录中。 这是一个自己的应用程序池中的自包含应用程序,所以我不认为SP是问题但是? aspx页面工作正常,但是对ApiController的请求返回401错误:Access是Deniend。
<html><head><title>Error</title></head><body>Error: Access is Denied.</body></html>事件查看器什么也没有,IIS日志显示401 2 2148074254然后401 1 0然后200 0 0然后401 1 2148074248.我知道最后401.1看起来像我的错误,但我已经多次确认它是请求的最后一个日志条目。 适用于IE8,Chrome,FireFox。
Fiddler只显示401,“WWW-Authenticate:NTLM”与“WWW-Authenticate:NTLM TlRMblah_blah_blah ......”和上面的HTML交替显示。
备份计划是放弃控制器并使用.ashx,但希望SO可以提供帮助。
I have an ASP.NET 4 app that I have in a virtual directory in my SharePoint site. This is a self contained app in its own app pool so I don't think SP is the problem but? The aspx page works fine, but a request to the ApiController returns 401 Error: Access is Deniend.
<html><head><title>Error</title></head><body>Error: Access is Denied.</body></html>Event Viewer has nothing and IIS log shows 401 2 2148074254 then 401 1 0 then 200 0 0 then 401 1 2148074248. I Know that last 401.1 looks like my mistake, but I have confirmed many times it is the Last log entry for a request. Consistant in IE8, Chrome, FireFox.
Fiddler shows only 401s, "WWW-Authenticate: NTLM" alternating with "WWW-Authenticate: NTLM TlRMblah_blah_blah..." and the HTML above.
Backup plan is to ditch the controller and use a .ashx, but hopefully SO can help.
最满意答案
找到解决方法,直到项目不再在SharePoint中。 保持Controler类(PSSController)原样,但添加了一个带有以下代码的ashx文件并更改了javascript以使用它。 cntrl只是我的班级; 你的QueryString和Post params会有所不同。 有点hacky但它的工作:)
using System; using System.Collections.Generic; using System.Web; using System.Web.SessionState; using Newtonsoft.Json; namespace PipWebApp { public partial class PSSurvey2API : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { String InputString = null; using (var sr = new System.IO.StreamReader(context.Request.InputStream)) InputString = sr.ReadToEnd(); List<PSSurvey.cntrl> cntrls = (List<PSSurvey.cntrl>)JsonConvert.DeserializeObject(InputString, typeof(List<PSSurvey.cntrl>)); String Params = context.Request.QueryString["Params"]; Controllers.PSSController APICon = new Controllers.PSSController(); if (context.Request.QueryString["Rpt"] == null) context.Response.Write(JsonConvert.SerializeObject(APICon.Post(cntrls, Params))); else context.Response.Write(JsonConvert.SerializeObject(APICon.Post(cntrls, context.Request.QueryString["Rpt"], Params))); } public bool IsReusable { get { return false; } } }}
Found a work-around until the project is no longer in SharePoint. Kept the Controler class (PSSController) as-is, but added an ashx file with the below code and changed the javascript to use it. cntrl is just my class; your QueryString and Post params will be different. A bit hacky but it works :)
using System; using System.Collections.Generic; using System.Web; using System.Web.SessionState; using Newtonsoft.Json; namespace PipWebApp { public partial class PSSurvey2API : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { String InputString = null; using (var sr = new System.IO.StreamReader(context.Request.InputStream)) InputString = sr.ReadToEnd(); List<PSSurvey.cntrl> cntrls = (List<PSSurvey.cntrl>)JsonConvert.DeserializeObject(InputString, typeof(List<PSSurvey.cntrl>)); String Params = context.Request.QueryString["Params"]; Controllers.PSSController APICon = new Controllers.PSSController(); if (context.Request.QueryString["Rpt"] == null) context.Response.Write(JsonConvert.SerializeObject(APICon.Post(cntrls, Params))); else context.Response.Write(JsonConvert.SerializeObject(APICon.Post(cntrls, context.Request.QueryString["Rpt"], Params))); } public bool IsReusable { get { return false; } } }}
更多推荐
发布评论