0

Kindly help. I am trying to add form authentication to an ASP.NET MVC application by adding the following in the web.config file:

</connectionStrings>
  <authentication mode="Forms">
    <forms loginUrl="Logins/Index" timeout="2880"/>
  </authentication>

The following is my target action:

public class LoginsController : Controller
{
    DataContext db = new DataContext();
    // GET: Logins
    public ActionResult Index()
    {
        return View();
    }

But when I run the application, I am getting the following error:

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module IIS Web Core Notification Unknown Handler Not yet determined Error Code 0x80070032 Config Error The configuration section 'authentication' cannot be read because it is missing a section declaration Config File ...\web.config Requested URL https://localhost:44354/ Physical Path
Logon Method Not yet determined Logon User Not yet determined

Config Source:

   14:   </connectionStrings>
   15:   <authentication mode="Forms">  <-- highlighted in red
   16:     <forms loginUrl="Logins/Index" timeout="2880"/>

More Information:

This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error. If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.

View more information »

Error message screenshot

Error message screenshot

6
  • are you sure you've structured your webconfig correctly? your auth tag should sit in the following structure: <configuration> <system.web> Commented Dec 28, 2020 at 22:56
  • The server on a IIS has limited access to the file system. The user when connecting to a IIS has default GUEST privilege and does not have access to the config file. You client is connecting to the IIS server and while processing the request the server gets an error and returns a response with the 500.19 error. Commented Dec 28, 2020 at 23:00
  • Hi David L. Thanks very much. I am fairly a newbie. I have placed it under <configuration> <system.web> and the error has gone but instead of returning the Logins/Index view, it's going to Home/Index. Any idea what the issue could be? Commented Dec 28, 2020 at 23:17
  • Hey jdweng, thanks for coming through... I am actually using iis express within visual studio. The error is gone thanks to David L apart from the issue I have just raised above Commented Dec 28, 2020 at 23:20
  • Check for the following post for some possible guidance concerning 'no redirect to login page' problem after you fixed the 500.19 error: stackoverflow.com/questions/29537707/… Commented Dec 29, 2020 at 1:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.