.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Determine if the page required authentication?

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net

I'm using Forms Authentication.  Is there a way to determine whether a page (or request) required authentication or not?  My site has logged-in areas, and logged-out areas (all set in web.config under authorization sections), and I'd like a good way to know if asp.net required authentication to be set or not.

I'm using ASP.Net 2.0

View Complete Post

More Related Resource Links

Authentication required, redirect to login page

Hi,I want authentication required for all webpages in a site. If i copy the url of any of the web page in the current site and paste it in the url address i should redirect to login page. If you have any solution please suggest it.

Crystal Report Asking for Database Authentication each time when I view Page.


Whenever I open my Crystal Report page, I am taken to the Database Authentication page where I am asked for

User name
Data Name

each time.

Is there a way to avoid this and I save these authentication in my page once.

I am using VS2005, C#.

Any Help will be appriciated.


HttpWebRequest Form Authentication Not Getting Past Login Page

Hey Guys,I am trying to use HTTPWebRequest to login to a site and then retrieve the page after login. However, it seems as if I can't get past the login. I also investigated with Fiddler and tried mimicking Fiddler almost completely and still no luck.Any idea what I am doing wrong?Thanks,Mohammed    Dim webRequest As HttpWebRequest Dim responseReader As StreamReader Dim responseData As String Dim postData As String = "login=testexpert@yahoo.com&password=testexpert" Dim cookies As CookieContainer = New CookieContainer() Dim requestWriter As StreamWriter Try 'post form data to page strUrl = "https://www.ideeli.com/login" webRequest = HttpWebRequest.Create(strUrl) webRequest.Method = WebRequestMethods.Http.Post webRequest.ContentType = "application/x-www-form-urlencoded" webRequest.CookieContainer = cookies webRequest.ContentLength = postData.Length requestWriter = New StreamWriter(webRequest.GetRequestStream) requestWriter.Write(postData) requestWriter.Close() 'recieve cookie webRequest.GetResponse().Close() 'now we send the cookie webRequest = HttpWebRequest.Create("http://www.ideeli.com") webRequest.CookieContainer = cookies responseReader = New StreamReader(webRequest.GetResponse.GetResponseStream()) responseData = responseReader.ReadToEnd() res

Form based authentication Sharepoint 2007 gets redirected to login page

Hi We have sharepoint 2007 site deployed on Windows server 2008, IIS 7.0.  We extended the web application to enable forms based authentication referring to link http://msdn.microsoft.com/en-us/library/bb975136(office.12).aspx#MOSS2007FBAPart1_Intro, we selected Kerberos instead of NTLM, behavior is like, when user tries to login into the site using OOB login.aspx, user again gets redirected to the login page. We tried to extend the web application again but this time we selected NTLM, but this time farm account (also is application pool identity) is not able login and exhibits same behavior as above, but for other users we are able to login. Has anyone come across this behavior? can anyone please guide me in correct the behavior? Regards, RK  Radhakrishna

Lotus Notes users get "Authentication Required" when viewing an alert email with a graphic

(This is a SharePoint 2007 question, but I only see SharePoint 2010 in the Forum options...kind of odd since SharePoint 2010 has not been released.)If our users open email alerts in Lotus Notes, and the email has an image, they are presented with a prompt for credentials that says:"Authentication RequiredEnter your username for Unkown at sharepoint.ourcompany.comUsername________________________Password________________________[ ] Save these in an Account in my address book[OK][Cancel]"Emails without graphics do not prompt for credentials.Does anybody know why this happens, or how we can fix it?

Forms Authentication sending user to LoginURL on first hit of page even though page has [allow users

On the first hit, and only the first hit, to my page having [ALLOW users="*"] in the web.config, the user is redirected to the LoginUrl, but on all subsequent visits to the page, the user IS allowed access.  The user shoud ALWAYS be allowed access to this page.  I suspect it is a configuration problem, so here are snippets of my web.config... <compilation debug="false" strict="true" explicit="true" /> <trace enabled="false"/> <authentication mode="Forms"> <forms protection="All" cookieless="UseCookies" requireSSL="false" slidingExpiration="false" timeout="20" name="12345678-1234-1234-1234-123456789012" loginUrl="~/Web/Login.aspx" defaultUrl="~/Web/MyPage.aspx" enableCrossAppRedirects="false" /> <authentication> <httpCookies httpOnlyCookies="true" /> <sessionState cookieless="UseCookies" />         <location path="Web/Contact.aspx"> <system.web> <authorization> <allow users="*"/> <authorization> <system.web> <location>   Can you help me figure out why users are not ALWAYS allowed access to the /Web/Contact.aspx page? Thx!      

Redirecting to login page while accessing document from document library In FBA Authentication

Hi all,            I have FBA site. When i open document from share point document library, it takes me to login page. After i enter credentials it will open page in client application ( ex. Microsoft word, microsoft powerpoint).   Regards Milan chauhan

Forms Authentication shared between 2 Applications, but still getting directed to login page

my scenario is: Single Sign-on Within a Sub Domain (two virtual directories under the same sub domain)I've setup both sites using the same forms authentication info in my web.config. both sites have the same machine key's as well. I sign into site1. i click a link that directs to site2. site2 still redirects me to the login page, however on the login page I test HttpContext.Current.User.Identity.IsAuthenticated and it returns true. I also tested on site2's login page to pull the ticket's information and it's pulling everything. so it looks like SSO is working as far as sharing the authentication ticket, yet I cannot figure out why it still puts me on the login page? site 1: https://mysub.mydomain.com/site1/ link in site1 that directs to site2: site 1: https://mysub.mydomain.com/site2/mypage.aspx any ideas? appreciate any help someone could give.

Required authentication

Hello, Is there a way to remove the message of authentication required each time I want to access a report. Thanks in advance Regards Aya

Forms Based Authentication - problem with custom master page and login page



I have successfully enabled and set up FBA (Forms Based Authentication) on my SharePoint 2010 Foundation server. The thing is that I need to customize the look and feel of the login page. I have successfully customized the page (and master page) to look the way I want, however, when I try to log in, I get the following error/message on the page:
"Forms Based Authentication on classic Web applications has been deprecated".

What I've done:
Made copies of /_layouts/simple.master and /_layouts/login.aspx and renamed the copies. The markup in the master page is MUCH simpler than the original, but I've kept all the ContentPlaceholders that I don't use (most of them) in a hidden <asp:Panel at the bottom of the page.

I've changed the web.config file:
<authentication mode="Forms">
      <forms loginUrl="/_layouts/loginCustom.aspx" />

So, I'm not getting any errors on the page until I try to log in. When I use the default settings (login.aspx and simple.master) it works just fine (but damn that page looks ugly!).

Does anyone know what I might be missing?

Update: I believe the reason it doesn't work is because my custom login aspx is not part of the Claims Based Web Application (because it's sitting

ASP.NET PageMethods - Back Button Causing 'Authentication Required' Prompt


Since last week I've had a really odd issue with PageMethods and the back button which i've never seen before.

Essentially, I have a 'home page' which on document.ready (using jQuery), loads some data through PageMethods, and then renders a list - from which you can click through to a details page about  the item. In general use, it works fine. However, using the back button after clicking through (ie: going back to the home page), it throws a PageMethods error. The browser's 'authentication required' prompt appears, and if you click cancel, the server returns a 404. The error returned by PageMethods on the client side is 'authentication failed'.

Just FYI, the application is using ASP.NET forms authentication. The weird thing is, this happens as soon as you click the link and click back. It's not like the authentication cookie has expired or anything, and if you click cancel when the prompt appears and refresh the page, it works fine. I just can't work out what is going on.

I've tried disabling caching on the page [as I thought it was something to down with some browsers' caches of the DOM), but the same thing happens.

One workaround i've had is to redirect the page to itself if the PageMethods error is 'authentication failed', which does work - but only when you cancel the authentic

download a page lose authentication/session state


Hi All,

I have an issue of keeping the authentication and session state on a downloaded page, on the same website.

I have 2 pages, page 1 will download page 2, using the following code:

Page 1 code:

System.Net.WebClient webClient = new System.Net.WebClient();
byte[] buffer = webClient.DownloadData("http://www.mywebsite.co.uk/page2.aspx");
return Encoding.UTF8.GetString(buffer);

but the authentication is lost, so i needed to re-login in page 2 by writing auto login code myself.
But then the session is lost, so the session variables set in page 1 cannot be share to page 2, and vice versa.

Ideally, i needed page 2 to keep the authentication and session state when i call webClient.DownloadData()

Is there a way to do this?
Many thanks!

authentication required


 i have a website where anonymous access is enabled, yet when i run it i get a box titled 'Authentication Required' and I have to enter a username and password


the text in the window says

enter username and password for "" at http://localhost


if i click cancel, the page starts to load, but the authentication window pops up again.  This happens several times, each time i cancel and eventually the page loads up ( a login page!) but its not being displayed correctly.


How can I get rid of this authentication window ?? 

Determine No of records per page


We have embedded SSRS 2008 reports into a web page using report viewer. Few reports are list reports, few are tablix with group by functions. Other reports using group are working fine, however we have group report which is displaying the records in a single page around 2000 records. If the parameter is changed to fetch 5000 records, again its in 1 page while other reports are splitting records into different pages.

Any idea? Why other reports using grouping have multiple page while this report doesnt?


Proxy Authentication Required


Hi guys,

I have an error at RSSWebPart:

"Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )"

Now web.config looks like:

<defaultProxy useDefaultCredentials="true">
      <proxy usesystemdefault="false" proxyaddress="http://<proxy>:8080" bypassonlocal="true" />

And user account under which Application pool is running has internet access.

Any ideas? Can I set user credentials in web.config?

disable a button if the required page has no data


Hi all

I have the following scenario and I'm not sure how to go about in resolving it.  Any ideas would gratefully recieved.

I have a page(A) with a button that when selected opens a new page(B) with a populated gridView.

However if the gridview hasn't got any data to display, rather than use the  <EmptyDataTemplate> within the gridview, I'd rather use disable/lock the button on page(A) thus preventing access to page(B)

Is this possible?  How on earth would I go about such a task ?

Windows authentication using SSRS 2008 R2 on separate machine from SQL db engine - Kerberos required


Is this still an issue in SSRS 2008 R2:  Can't use Windows authentication (integrated security) when the SQL database server is on a different machine than Reporting Services -- unless you (1) use Kerberos security, or (2) store credentials, or (3) use credentials supplied by the user when running report AND use as Windows credentials to impersonate?

I have SSRS 2008 R2 set up on a different machine than MSSQLServer 2008 R2.  When I create a report on the SSRS server that uses a data source specifying Windows integrated security, my symptom is that I get the following  error:

Cannot create a connection to data source 'myDataSource'. ---> System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

Here is a blog describing the problem under SSRS 2005 (with IIS): http://blogs.msdn.com/b/jgalla/archive/2006/03/16/reporting-services-and-windows-authentication.aspx



Richard Thompson
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend