I am with boring problem that is taking too much time from myself. I have an Web Application in ASP.NET MVC working properly when I run the project directly from my machine. Otherwise, when I publish the project on server (Windows Server 2012) I try to make it works on my machine, but it is the problem.

I can access the website normally, but when I access the register edition part of website and try to update some information, return me a message saying that the object reference is not set to an instance of an object. Accessing the website local, on my machine or even in server, it works, but remote access it doesn't work.

I did the same test on other servers and everything works fine, even remote access, but in Windows Server 2012 with IIS 8 I have this error message every time. I did the teste on an Windows Server 2008 and the website worked fine.

Anybody can help me to find a way to fix it? It's making me crazy. I already tried to uncheck the read only from folders of the project, but no success too. And before anyone asks me, the model is filled, because it is used before the code with problem.

Below you can see the part of the code with is returning the error message.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

Line 378:                        else

Line 379:                        { 

Line 380:                            @Html.DropDownListFor(model => model.CodigoCategoria, ViewBag.ListaCategorias as SelectList, new { @class = "big oculto" })

Line 381:                            <input id="CodigoCategoria-textbox" class="disabled" readonly="readonly" style="vertical-align: top; width: 367px" value="@Model.Categoria.Descricao" />

Line 382:                        }

Source File: c:\Karcher\Portal\Views\FichaCliente\Editar.cshtml    Line: 380 

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page_Views_FichaCliente_Editar_cshtml.Execute() in c:\Karcher\Portal\Views\FichaCliente\Editar.cshtml:380
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +97
System.Web.WebPages.StartPage.RunPage() +17
System.Web.WebPages.StartPage.ExecutePageHierarchy() +62
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +260

Tks in advance for any help!

Related posts

Recent Viewed