1

I am facing a big problem that is doesn't let me access my web application. Resuming all, I developed a web api with asp.net using the VS2013 with .NET framework 4.5.1 in a machine. I have published the application and I put in server that I need to use with Windows Server 2008 and IIS 7. When I try to use my application, any request that uses api link returns me Error 500 (Internal Server Error). Why?

I've already read many tutorials on Internet, I have tried all of them but it is still not working. I've already tried to remove something from my web.config and add another things, but everytime I change, another different error returns me like "The OWIN manager is not configured", something like that.

Below you can see the important parts from my 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>

And the problem that I am facing now is:

<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>

UPDATE

This is the code where we suppose that we can find the problem. Remembering that this error is returning because I am publishing the app in another server.

[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;
            }

Do you guys can help me? Any suggestion about what can I do? I really need your help.

Thanks a lot in advance!

  • Does this help? https://stackoverflow.com/a/30249774/752527 – Hanlet Escaño Dec 13 '17 at 16:54
  • Tks for your repply, but I had already seen this before. I checked this dll in my bin folder and it is there, as well as all other dlls. It must be in bin folder only, right? – Alison Vieira Dec 13 '17 at 16:58
  • Gotcha. It is a good idea to explicitly include what you have tried for this very reason. The dll's should be there, but also your project should be referencing them. – Hanlet Escaño Dec 13 '17 at 17:11
  • You mean this? – Alison Vieira Dec 13 '17 at 17:18
  • 1
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) –  Dec 13 '17 at 18:09
  • I don't think so. The message is 500 (Internal Server Error) which I think is something about accessing the api link or permissons. Any idea about these two that I can test or do something to check? – Alison Vieira Dec 13 '17 at 18:22
  • 1
    A 500 error just means you had an error **server-side**. It does not indicate anything about the nature of the error, and it certainly doesn't indicate anything about access permissions, which would be 400 errors. You're question says you are getting a `NullReferenceException`. That is the error you need to resolve. Did you read the error you're getting? You have a stack trace pointing to your `LinksController.GetLinks_All()`. –  Dec 13 '17 at 19:14
  • Tks Amy for your suggestion. So, let's think about what you mean. I understand that we suppose the app is trying to get some data and it returns null, so the app recognize the api link. Well, I have the code [HttpGet][AllowAnonymous][ResponseType(typeof(IEnumerable))]public IEnumerable GetLinks_All() {List 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; } ..do you see something wrong here? – Alison Vieira Dec 13 '17 at 22:41
  • (continue)..remembering that in my computer it works, but on this server not.. that is the reason I think something is missing in app configuration – Alison Vieira Dec 13 '17 at 22:42
  • Edit your question and add your code there. Code in comments is not readable. –  Dec 13 '17 at 22:59
  • OK Amy. Done! =D – Alison Vieira Dec 13 '17 at 23:21
  • " I have published the application and I put in server " Just making sure: did you test this specific API call (GetLinks_All()) in your development environment? – DaniDev Dec 14 '17 at 01:01

0 Answers0