Click here to Skip to main content
14,391,105 members
Rate this:
Please Sign up or sign in to vote.
Hi,

Here i am going to publish my web application on IIS 7.0 . Here I want forms Authentication so that i can login using my credential (or validating user).

When i am going to publish my web application on IIS using Forms Authentication it gives error message like

HTTP Error 401.2 - Unauthorized
You are not authorized to view this page due to invalid authentication headers.


What I have tried:

This is my web.config code
<authentication mode="Forms">
  <forms defaultUrl="~/frmHome.aspx" loginUrl="~/frmLogin.aspx" slidingExpiration="true" timeout="2880"></forms>
    </authentication>


and in iis setting i did following
1. Forms Authebication mode enabled.
2. Set Default document
3. Allow Directory browsing
4. Inside Basic setting i chosen Default application pool.
5. Given Fill access rights to virtual directory.

Please Help me.
for above problem
Posted
Comments
digimanus 23-Oct-18 4:25am
   
What authorisations have been setup in IIS for the webapplication?
SujataJK 23-Oct-18 4:26am
   
Forms Authentication
digimanus 23-Oct-18 4:27am
   
Forms Authentication is Enabled under authentication? Is that what you are telling me?
digimanus 23-Oct-18 4:28am
   
Can Fiddler give you more details about:
'You are not authorized to view this page due to invalid authentication headers.'
SujataJK 23-Oct-18 4:36am
   
in iis ,inside authorization rules section i allow all user and entry type is local
SujataJK 23-Oct-18 4:38am
   
Above error message also shows following details

Most likely causes:
1. No authentication protocol (including anonymous) is selected in IIS.
2 Only integrated authentication is enabled, and a client browser was used
that does not support integrated authentication.
3 .Integrated authentication is enabled and the request was sent through a proxy that changed the authentication headers before they reach the Web server.
4. The Web server is not configured for anonymous access and a required authorization header was not received.
5. The "configuration/system.webServer/authorization" configuration section may be explicitly denying the user access.
digimanus 23-Oct-18 5:17am
   
has your webapplication a global.asax file that handles unhandled exceptions?
SujataJK 23-Oct-18 6:29am
   
I did this in global.aspx

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
MailMessage msg = new MailMessage();
HttpContext ctx = HttpContext.Current;

msg.To.Add(new MailAddress("sujata.shinde@jkumar.com"));
msg.From = new MailAddress("sujata.shinde@jkumar.com");
msg.Subject = "My app had an issue...";
msg.Priority = MailPriority.High;

StringBuilder sb = new StringBuilder();
sb.Append(ctx.Request.Url.ToString() + System.Environment.NewLine);
sb.Append("Source:" + System.Environment.NewLine + ctx.Server.GetLastError().Source.ToString());
sb.Append("Message:" + System.Environment.NewLine + ctx.Server.GetLastError().Message.ToString());
sb.Append("Stack Trace:" + System.Environment.NewLine + ctx.Server.GetLastError().StackTrace.ToString());
msg.Body = sb.ToString();
Response.Write(sb.ToString());
// msg.Body = sb.ToString();

//CONFIGURE SMTP OBJECT
System.Net.Mail.SmtpClient smtCliend = new System.Net.Mail.SmtpClient();
smtCliend.Host = "smtp.logix.in"; //Or Your SMTP Server Address
smtCliend.Port = 587;
smtCliend.UseDefaultCredentials = false;
smtCliend.Credentials = new NetworkCredential("sujata.shinde@jkumar.com", "S@ujata321");

//SEND EMAIL
smtCliend.Send(msg);

}
digimanus 23-Oct-18 9:08am
   
And you are not getting mails when starting up the webapplication?
SujataJK 24-Oct-18 1:12am
   
I got mail including this warning message
http://localhost/JKWorkBewnch/frmLogin.aspx

Source:
System.WebMessage:
Exception of type 'System.Web.HttpUnhandledException' was thrown.Stack Trace:
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.frmlogin_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\jkworkbewnch\673b1ad7\11d2590e\App_Web_ykh4oa1j.2.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Refresh Refresh
Compose Compose
Print
Move selected item(s) to Trash
SujataJK 24-Oct-18 2:32am
   
Finally i resolve my issue.
digimanus 24-Oct-18 2:52am
   
What was it?
SujataJK 24-Oct-18 3:20am
   
Here i have changed DefaultApplicationPool Identity from NetworkService To LocalSystem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100