C# - Process A Page Event Prior To Forms Authentication Redirects?
Mar 8, 2010
I have a website that uses basic ASP.Net forms authentication. In the web.config file we specify specific access rules for individual pages and directories. Everything works great.
However, now I have some new requirements. My domain contains many different sites setup among different subdomains. I have two DNS subdomains that map to this application. One is aaa.mysite.com and the other is www.mysite.com. If a particular web request is received from subdomain aaa.mysite.com for a page protected by FormsAuthentication, before the FormsAuthentication logic is handled (the user would be re-directed to the login page), I want to execute some code first. This code would essentially try to read a cookie from a third subdomain, say zzz.mysite.com, and if does not exist, Response.Redirect to a login page in the zzz.mysite.com application.
I tried handling this via a base class that any of my Forms Authentication protected pages could inherit from, and then calling the special code in the Page_PreInit function. However, FormsAuthentication handles the redirect to the Login page even before the PreInit function is called.
Does anyone know a good way to handle this case? If Page_PreInit won't work, where can I put code so that it executes prior to the FormsAuthentication redirect does, but where I also have access to which page it is (and what class it inherits from, so I can see if it inherits from System.Web.UI.Page or if it inherits from my special BasePage).
I think I could use the Globals Application_BeginRequest, but then this would be called for every single request, which doesn't seem like a very good idea.
I can't be the first person who has needed a way to handle an event prior to the FormsAuthentication
View 2 Replies
Similar Messages:
May 20, 2010
I have two webpages. Default.aspx and Default2.aspx
No code written in both pages.
I put an imagebutton without imageurl in Default2.aspx
The control is redirected to Default.aspx when Default2.aspx requests...
How does this happen?
View 2 Replies
Feb 21, 2011
I would periodically get a message stating "too many redirects". I used debug this moring and found out that my login page, even with no code in the page_load and no script does 9 redirects back to itself. I use forms authentication and assume it has something to do with that.
View 3 Replies
Jul 23, 2010
if users press the browser's back button to reach the prior page..then page should display a message like "web page expired" in asp.net can i use javascript for this?
for example..
there are 4 pages in web sites. 1,2 and 3 can be back. but when the 4th page run then 4th page can not be back... when the user press browser's back button , diaplay ma message "weg page expired".
View 4 Replies
Mar 29, 2010
when i run my webpage my personal webserver automatically redirects page to iisstart.htm page.my webageis not showing. what could be the problem?
View 12 Replies
Jan 15, 2010
I have inherited a site that was developed with a very over architedcted Content Management System. I am having problems now with the redirection functionality built into it.
This is on a dedicated Windows 2003 server running ASP.NET 3.5 sp 1. The redirects are stored in the database, and I have confirmed that the correct redirect is in place in the database. Finally, the file extension .html has been mapped in IIS to the ASP.NET ISAPI. And there is an HttpHandler created to redirect the .html requests. The default documents on the server, in order, are:
default.aspx
index.aspx
default.asp
index.asp
default.html
index.html
for this example, we have two redirects both pointing to the same content page. /example and /example.html.when requesting /example.html it correctly finds the appropriate redirect in the database and does its magic. Bueno. When requesting /example it gives a 404 page. Its not even the asp.net yellowish 404 generic error page. Its the standrad vanilla IIS 404 response so it appears that asp.net is not intercepting these requests.
View 3 Replies
Oct 26, 2010
i want a event/process specific progress bar...
i.e. in a form i will take the inputs from the client and then save it in database and show some after result to client...
so in between i want to display the progress bar that 10% 27% 36% ..... 100% complete or any loading.gif image.
if the saving the form will take 1 min then the progress bar is on for 1 min or else if saving take 10 sec then progress bar is for 10 sec...
View 5 Replies
Mar 2, 2011
How do I disable a button in an ascx page? I know how to do it on an aspx page with:
btnSave.Attributes.Add("onclick",
"this.disabled=true;this.value='Please Wait...';needToConfirm=false;" +
ClientScript.GetPostBackEventReference(btnSave, "").ToString());
But the ClientScript function is not present in the ascx page.
View 4 Replies
Sep 23, 2010
I want to dynamically build a table where each of the first three cells may or may not contain an image. If a cell contains an image, it may or may not contain a radio button. The last cell contains a button or link button. I want all the buttons to be handled by the same click event. The number of rows, which cells will have an image, and which cells will have a radio button is not known at design time. Finally, the images are displayed using the better image control.
I'm trying to get this to work usinging a repeater, but at the moment I can't get the radio button checked propety to change from the default value. I'm using an arraylist as a datasource. I thought of using a gridview, but I don't know how to add a radio button and a better image control to a cell.
View 4 Replies
May 24, 2010
I get two frames, says A and B. Clicking a link in A will trigger page in B changing from URL_A to URL_B.
How do I remember URL_A, so that when users click cacnel button in URL_B, they can go back to URL_A?
how do I get mainFrame's URL in fraTopMenu?
<frameset rows="60,*" cols="*" frameborder="no" border="0" framespacing="0">
<frame src="/Common/Manager/TopMenu.aspx" name="fraTopMenu"
scrolling="no" noresize="noresize" id="fraTopMenu" title="" />
<frameset rows="*" cols="185,*" framespacing="0" frameborder="no" border="0">
<frame src="/Common/Manager/LeftMenu.aspx" name="leftFrame" id="leftFrame"
title="" />
<frame src="<%= MainUrl %>" name="mainFrame" id="mainFrame" />
</frameset>
</frameset>
View 2 Replies
Jun 29, 2010
I have a products page, with a treeview on left, (telerik) and on the right there is a div. The div on the right is used to load stuff in it, (using jquery, calling another aspx with a querystring parameter), called from Telerik Treeview's client-side OnNodeSelecting event ... Everything works as expected. There is also a RadioButton list (asp.net rbl) on top of this page, that is set to AutoPostBack. It switched the current language of the page. In all the other pages, it changes the Language and reloads the page. Then browsing the proıducts is pure client-side by loading into the rihgtmost div, (jquery calling another aspx page with a parameter, and loads the resulting HTML into the div).
What happens is, once I load content into this div, and then try to select another language from the RadioButtonList, whole window redirects to the aspx page that is supposed to provide the content to jQuery load. I have absolutely no clue why that happens.
Code below:
TreeView is actually inside an ascx. The client-side code is
$(document).ready(function() {
loadproduct(getDefaultUrl());
});
function getDefaultUrl() {
var hf = document.getElementById('ctl00_cphContent_hfLastSelectedProductUrl'); ///this is for preserving the state
var url = hf.value;
return url;
}
function UrunMenuNodeClicking(sender, args) {..........
note: the Class MyControl inherits from System.Web.UI.UserControl , and has a property that accesses Session and sets the current language as an integer. Actually it is an enum like Languages.English, I do (int)enum and send it to session ...
View 2 Replies
Sep 28, 2010
I have a SqlDataSource setup in the markup on my page. After some new requirements, I am trying to find a way to modify the SelectCommand before the data is filled for the first time. The SelectCommand below will now be used by default since we'll always have the first param. I am faced with a need to modify the SelectCommand though, adding a second session parameter along with it. I tried to override the OnInit method but it didn't seem to help...it still used the default query. Is there a best way to accomplish this? Here is the section of markup I am referring to:
[code]....
View 2 Replies
Sep 7, 2010
I'm building an ASP.NET 3.5 webapplication using VB.NET, and I'm having problems redirecting to another URL when using Google Chrome. Other browsers like IE and Firefox are fine.
My data entry forms all have an OK and an Cancel button, which are both handled server-side. The Cancel button just redirects back to the originating page, while the OK button will add or update a database record and then redirect to the originating page.
The redirect to the originating page is done by calling the following shared sub on a general utilities class in my appication:
[Code]....
As you can see, I've tried using the extra argument in the response.Redirect call, but that doesn't make a difference. All browsers except Google Chrome redirect fine, but Chrome does not redirect at all. When pushing the Cancel button nothing seems to happen. And when pushing the OK button, the corresponding database record is added or updated, but the redirect to the originating page doesn't happen. This Chrome redirect problem occurs only on the production server. When running the application at 'localhost' there is no problem. what might be causing this redirect issue in Google Chrome?
View 9 Replies
Sep 28, 2010
I am trying to extend controller with extension method which redirects to 404 page.
[Code]....
However, controller.View() method is internal and can't be called outside class methods.
View 3 Replies
May 7, 2010
on page refresh it redirects to login page. why?
View 1 Replies
Feb 9, 2011
I have a very simple app where a user enters 2 text values and presses a button, I want a confirmation message to be displayed on the same page however it keeps redirecting to show the partial view as a full view.
This is my home View:
[Code]....
This is my ContactController:
[Code]....
And finally this is my Confirmation PartialView
[Code]....
This is using MVC 3/.Net 4, I have downloaded an MVC 2/.Net3.5 sample project from the web that is doing exactly the same which works fine. What am I doing wrong?
View 7 Replies
Oct 20, 2010
I'm trying to set up the SSL in my web app, but don't know if i'm doing it right, or if even i'm taking the right steps in the right order.I have a function in a class that returns the secure URL (https://mydomain.com/...aspx) if the current url is not secure (http)
[Code]....
(Though in develop environment It's like "https://localhost:port" + rawUrl)
when the function returns ssl value, if it's not empty, then the master page redirects to the new url... but the browser is not showing it...
View 5 Replies
Sep 14, 2010
I am having an issue where if I change my url to .asp from .aspx i get a 404 error but it is not handled by my custom errors. If I change the url to def23947823h.aspx it is caught and redirects to correct page.
[Code]....
View 8 Replies
Sep 3, 2010
I'm trying to save some content whenever a button/hyperlink is clicked using jquery.ajax (Using Asp.net 3.5). The logic is as follows:
Through .bind in jquery I bind my own method(MakeLog) to a button click or hyperlink click. The click events of button/hyperlink contain nothing, I need to use .bind for selective controls.Now we have a button whose click event will fire a method, say MakeLog.Code snippet for MakeLog is as follows:
var xhr = jQuery.ajax({
url: "/Logger.aspx",
data: { content: logContent }, [code]....
This works fine in IE but in Firefox this is not sending the data back as expected.I tried to identify the issue and came across the following: http://stackoverflow.com/questions/3522944/jquery-ajax-calls-async-false-vs-async-true .What I understand is that, whenver page is redirecting/reloading due to button click or hyperlink click the async call is not working properly.
View 1 Replies
Apr 3, 2010
I've developed a popup email .aspx used on our intranet based web app that is auto generated with .pdf's attached. I'm developing with VS 2008 ASP.Net 3.5 C# and System.Net.Mail.MailMessage. I can create and send the email with no issues. The problem is with any attempt to open or delete the attachments I get the above error. The .pdf's a copied with the following code:
FileStream fsr = new FileStream(inFilename, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryReader reader = new BinaryReader(fsr);
byte[] bytes = new byte[fsr.Length];
reader.Read(bytes, 0, bytes.Length);
FileStream fsw = new FileStream(outFileName, FileMode.Create, FileAccess.Write, FileShare.Write);
BinaryWriter writer = new BinaryWriter(fsw);
writer.Write(bytes, 0, bytes.Length);
// clean up
writer.Flush();
writer.Close();
writer = null;
fsw.Close();
fsw.Dispose();
fsw = null;
reader.Close();
reader = null;
fsr.Close();
fsr.Dispose();
fsr = null;
Later after sending the email I:
mailMessage.Dispose();
mailMessage = null;
foreach (string fileName in attachments)
{
if (File.Exists(fileName))
File.Delete(fileName);
}
The error occurs at: the File.Delete(fileName);
how I can delete or reopen these files after sending the email?
View 9 Replies
Nov 6, 2010
My code is that I want to create a log file and log it upon a new user browsing the site. However, what i did was I put in a 6 second delay and then used another browser to access the page. And it threw an Exception saying it is being used by another process which is true. So how come I set it so that, if IT is being used by another process, WAIT and retry every 500 milliseconds until it becomes free/available?
here's the code:
protected void Page_Load(object sender, EventArgs e)
{if (!IsPostBack) // if this is the first time page loads, set k to 1
{ lognewuser();
}}
[Code]....
View 1 Replies
Dec 10, 2010
im using asp.net for my webpage. im also using the login control too. i want it so when the user types in the correct user name and password, it redirects to a new page called test.aspx. i dont want to use login view.
View 2 Replies
Oct 13, 2010
I have a ASP.NET Login Control with Forms authentication.Even after successful Login it does not redirects to destination page.But it uses returnURL and stays at same Login page.How to make Login Control to redirect to specified destination page?
View 1 Replies
Aug 18, 2010
I've made a for a web app to use sql server session state, in the event viewer I get a re-occuring informatation message:
Event code: 4005
Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.
Event time: 17/08/2010 10:37:01
Event time (UTC): 17/08/2010 09:37:01
Event ID: 623a3b87c23541b9b8b49d9a9a167bde
Event sequence: 7699
Event occurrence: 124
Event detail code: 50202
Process information:
Process ID: 10188
Process name: w3wp.exe
Account name: NT AUTHORITYNETWORK SERVICE
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITYNETWORK SERVICE
It dosnt seem to be causing any problems, just filling the event viewer...
View 3 Replies
Mar 11, 2010
I started creating a new website in Visual Studio 2008 and in my site, there are two pages such that clicking treenode on parent page will take the user to second page. But when i execute my project and then stop the debugging from IDE, the child window is not getting closed. I am not sure where i am missing.
View 1 Replies