我遇到一个大问题,就是不让我访问我的网络应用程序。恢复所有,我在一台机器上使用带有.NET framework 4.5.1的VS2013与asp.net开发了一个web api。我已经发布了应用程序,并且我放入了需要与Windows Server 2008和IIS 7一起使用的服务器。当我尝试使用我的应用程序时,任何使用api链接的请求都会返回错误500(内部服务器错误)。为什么呢?
我已经在互联网上阅读了很多教程,我已经尝试了所有这些教程,但它仍然无法正常工作。我已经尝试从我的web.config中删除一些内容并添加其他内容,但每次我更改时,另一个不同的错误都会让我回复“OWIN manager is not configured”,就像那样。
下面你可以看到我的web.config中的重要部分。
<appSettings>
<add key="owin:AppStartup" value="MyNamespace.Startup" />
<add key="owin:AutomaticAppStartup" value="true" />
</appSettings>
<system.web>
<identity impersonate="false" />
<compilation targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" maxRequestLength="51200" executionTimeout="3600" />
<customErrors mode="Off" />
</system.web>
<modules runAllManagedModulesForAllRequests="true">
<remove name="FormsAuthenticationModule" />
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
我现在面临的问题是:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Object reference not set to an instance of an object.
</ExceptionMessage>
<ExceptionType>System.NullReferenceException</ExceptionType>
<StackTrace>
at PS_VirtualCalendar.Services.Controllers.LinksController.GetLinks_All() at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
</Error>
更新
这是我们可以找到问题的代码。记住这个错误正在返回,因为我正在另一台服务器上发布该应用程序。
[HttpGet]
[AllowAnonymous]
[ResponseType(typeof(IEnumerable<ent_Links>))]
public IEnumerable<ent_Links> GetLinks_All()
{
List<ent_Links> list_Links;
ent_Links oEnt_Links;
try
{
using (BL_Links _srv = new BL_Links())
{
oEnt_Links = new ent_Links();
list_Links = _srv.BL_Links_GetList(oEnt_Links);
}
}
catch (Exception e)
{
throw e;
}
return list_Links;
}
你们可以帮帮我吗?关于我能做什么的任何建议?我真的需要你的帮助。
提前多多感谢!