Click here to Skip to main content
15,434,964 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good morning to all in my project i send mails in my web configure file i added the following code to redirect the user to login page while copy the url and paste the code is "<deny users="?">" if i add the above code and then i got the following error when send mails the error is
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
Quote:
Stack Trace:

[WebException: The remote server returned an error: (401) Unauthorized.]
System.Net.HttpWebRequest.GetResponse() +1205
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +103

[MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +239
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1114
Ncoretech.WebUX.AdminMenuSearchService.IAdminSearchService.GetRestaurantCities() +0
Ncoretech.WebUX.AdminMenuSearchService.AdminSearchServiceClient.GetRestaurantCities() in C:\Inetpub\wwwroot\Ncoretech-Admin\solution\Ncoretech - Web\Ncoretech.WebUX\Service References\AdminMenuSearchService\Reference.cs:7541
Ncoretech.WebUX.Adminstrators.SendAllTypeOfMails.CityName() in C:\Inetpub\wwwroot\Ncoretech-Admin\solution\Ncoretech - Web\Ncoretech.WebUX\Adminstrators\SendAllTypeOfMails.aspx.cs:68
Ncoretech.WebUX.Adminstrators.SendAllTypeOfMails.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Ncoretech-Admin\solution\Ncoretech - Web\Ncoretech.WebUX\Adminstrators\SendAllTypeOfMails.aspx.cs:28
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +46
System.Web.UI.Control.OnLoad(EventArgs e) +83
System.Web.UI.Control.LoadRecursive() +120
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3940


my web configure file like as
<security mode="Message">
<transport clientcredentialtype="Windows" proxycredentialtype="None"> realm="" />
<message clientcredentialtype="Windows" negotiateservicecredential="true">
algorithmSuite="Default" />





if i delete the "<deny users="?">" line there is no broblem but not redirect to login page please help me anyone



thanks in advance
By
Meganathan M
Posted

Hi,

Use authentication properly and set the login page to login.aspx there in web.config file. You don't need to worry. Asp.net authentication will do it automatically. Refer these links:
From Custom Authentication to ASP.NET Forms Authentication[^]
http://msdn.microsoft.com/en-us/library/ms178329.aspx[^]
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.authenticate.aspx[^]
http://stackoverflow.com/questions/2686946/asp-net-authentication-login-and-logout-with-browser-back-button[^]

All the best.
--AK
 
Share this answer
 
Comments
Sandeep Mewara 14-Jun-12 16:09pm    
My 5!
[no name] 16-Jun-12 1:41am    
Thank you Sandeep sir,..
"If I have project.aspx and login.aspx"

On your project.aspx.cs Page Load
simply write

if ((HttpContext.Current.Request.UrlReferrer == null))
{
Response.Redirect("login.aspx");
}

This will redirect you back to Login page.
Hope this solves your problem.

Adejumo
 
Share this answer
 
Comments
CHill60 25-Oct-15 10:39am     CRLF
Please don't post more than one solution to a question, it is confusing for the OP and for anyone else trying to work out which is the correct answer. Use the Improve solution link if you want to add anything to your first post. Also avoid answering old questions unless you are sure you are bringing something new to the discussion - and that you are accurately interpreting the problem and providing a solution - which you are not in this case.
ARAVIND.KOTTAPALLI 14-Dec-21 1:43am    
Worked like a charm. Thank you very much. saved lot of time.
C#
if ((HttpContext.Current.Request.UrlReferrer == null))
{
    Response.Redirect("Default.aspx");
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900