Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:51:40+00:00 2026-06-18T08:51:40+00:00

IIS Throws: Object reference not set to an instance of an object. when it

  • 0

IIS Throws:

Object reference not set to an instance of an object.

when it is supposed to redirect a authenticated user to /Home/Index

I have investigated the reason it might be happening and can´t find the reason

The line is that:

return RedirectToAction("Index", "Home");

stacktrace: (That is the only information I get)

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.Mvc.AuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) +30
   System.Web.Mvc.AuthorizeAttribute.OnAuthorization(AuthorizationContext filterContext) +160
   System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +97
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback asyncCallback, Object asyncState) +445
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +287
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__17(AsyncCallback asyncCallback, Object asyncState) +30
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +338
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +282
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +15
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__2(AsyncCallback asyncCallback, Object asyncState) +71
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +236
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Edit 1:
The application is working locally in my computer. I am coping all the folder and sending to the server. Then, I try to access locally in the server and I get this. IIS on the server has the same configuration for Application Pool and I believe it is configured right, at least for a local use as I am doing. I am trying to get it to work locally in the server and then I´ll configure for remote use.

Edit 2:

This is /Home/Index:

namespace gedaiapp.Controllers
{
    [Authorize]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {   
            return PartialView();
        }
    }
}

and the /Index/Login (Class has authorize attribute, only this specific method has [AllowAnonymous]) so users not yet authenticated are allowed to login

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, FormCollection form)
{
    try
    {
        //Verifica se logon será feito utilizando certificado digital ou não
        string isDigitalCertified = form["hasDigital"];

        if (!string.IsNullOrEmpty(isDigitalCertified))
        {
            string[] isDCArr = isDigitalCertified.Split(',');

            if (!string.IsNullOrEmpty(isDCArr[0]))
            {
                string isDC = isDCArr[0];

                //Se login for utilizando certificado digital
                if (isDC == "true")
                {
                    //Resgata subject do certificado digital
                    string certDadosStr = "";
                    do
                    {
                        certDadosStr = Request.ClientCertificate.Subject;
                    } while (certDadosStr == "");

                    //Resgata cpf ou cnpj do certificado digital
                    string[] certDadosArr = certDadosStr.Split(',');
                    int Count = certDadosArr.Count();
                    //Razão social é sempre o último elemento no padrão ICP-Brasil
                    string razaoSocial = certDadosArr[Count - 1];
                    string[] razaoSocialArr = razaoSocial.Split(':');
                    Count = razaoSocialArr.Count();
                    string key = razaoSocialArr[Count - 1];
                    //Resgata Guid do usuário
                    MembershipUser user = Membership.GetUser(model.UserName);
                    Guid userID = (Guid)user.ProviderUserKey;

                    //Verifica se (cpf ou cnpj) do usuário efetuando o login é o mesmo do cadastrado no sistema
                    using (gedaiappEntities context = new gedaiappEntities())
                    {
                        var keyNumberObj = from a in context.sistema_UsersCertified
                                           where a.userID == userID
                                           select a.keyNumber;
                        string keyNumber = keyNumberObj.First();

                        //Se autenticidade for positiva (redireciona)
                        if (keyNumber == key)
                        {
                            FormsAuthentication.SetAuthCookie(model.UserName, false);
                            return RedirectToAction("Index", "Home");
                        }
                        else
                        {
                            return RedirectToAction("Login", "Account");
                        }
                    }
                }//Caso login seja sem certificado digital
                else
                {
                    MembershipProvider mp = Membership.Provider;
                    if (mp.ValidateUser(model.UserName, model.Password))
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, false);
                        try
                        {
                            return RedirectToAction("Index", "Home");
                        }
                        catch (Exception e)
                        {
                            return Content("Erro: " + e);
                        }

                    }
                    return RedirectToAction("Login", "Account");
                }
            }
            else
            {
                //return Content("Erro Catastrófico: Não foi possivel identificar se login é com certificado digital ou não.");
                return RedirectToAction("Login", "Account");
            }
        }
        else
        {
            //return Content("Erro Catastrófico: Valor do checkbox hasDigital não foi enviado.");
            return RedirectToAction("Login", "Account");
        }
    }
    catch (Exception e)
    {
        return Content("Erro: " + e);
    }
}

Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:51:41+00:00Added an answer on June 18, 2026 at 8:51 am

    Solved the problem adding

    <modules runAllManagedModulesForAllRequests="true"/>

    in the web.config

    P.S. It is not the right way to do as it will load all modules at every request. Although can´t find what is not loading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In IIS 5.1, i have set the website security to Basic Authentications and i
I have a remoting server hosted under IIS that is throws the following exception
We installed IIS on two servers. On the first server we have access to
I have IIS 7.5 With one web site I added new virtual directory and
I am using IIS 6 on 2003. I have created a HTTP handler dll
I want to be able to generate IIS's standard 404 response, not a custom
I have an app that accesses information about websites running on IIS on a
I have following class that returns number of current Request per Second of IIS.
I'm experiencing problems with an exception not caught in my workflows. I have a
Hi, I have a service hosten in IIS that runnes this code : DirectoryEntry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.