CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 7/31/2006 1:37:38 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 58 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
audun.net
Asp.Net User
newbie: Works in webpage, but NOT in masterpage, why?7/31/2006 1:37:38 PM

0/0

hey

asp.net 2.0

In my web portal I got several webpage and a masterpage (ContentMaster.aspx). The webpages uses this masterpage...

In the Page_Load event of ContentMaster.aspx I want to redirect the user to another webpage if he is an anonymous user

if (Profile.IsAnonymous)
{
           Response.Redirect("~/join.aspx");
 }

This is causing this error:

An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll but was not handled in user code
The program '[5196] WebDev.WebServer.EXE: Managed' has exited with code 0 (0x0).

But if I remove this code from ContentMaster.aspx and place it in the Page_Load event of a webpage. (webpage based on ContentMaster.aspx) then it works....

Why isn't the code working if it's placed within Page_Load of contentmaster.aspx? what should I do to make it works in the Page_Load event of contentMaster.aspx?

Audun

 

stiletto
Asp.Net User
Re: newbie: Works in webpage, but NOT in masterpage, why?7/31/2006 1:52:02 PM

0/0

The thread abort is being done by the Redirect.  That's just how it works.

The issue is that the MasterPage is loaded external to the page based on it and then inserted into the control heirarchy to wrap the page's controls.  Evidently the code that instantiates the MasterPage doesn't like having a Redirect.

I'd recommend creating a base page class that inherits from Page and contains the redirect.  This will move the redirect from your MasterPage, which should only contain presentation logic, and put it in a single place for you entire app to consume.

audun.net
Asp.Net User
Re: newbie: Works in webpage, but NOT in masterpage, why?7/31/2006 3:56:03 PM

0/0

Thanks for your reply!

I forgot to mention that I use Visual Wev Developer 2005 Express, I'm not sure I can inherit classes within that IDE. Anyway I don't see any menu items if I right click in the "solution explorer" which have somthing to do with inheriting

But I'm a newbie and could easly have overlooked a option in my IDE... if I can't inherit, then I place the code in every page... It isn't so many pages. about 7 web pages....

Audun

stiletto
Asp.Net User
Re: newbie: Works in webpage, but NOT in masterpage, why?7/31/2006 4:53:36 PM

0/0

To inherit just define your new class like (C#):

public MyInheritedPage : System.Web.UI.Page

soccerdad
Asp.Net User
Re: newbie: Works in webpage, but NOT in masterpage, why?7/31/2006 5:00:08 PM

0/0

I have code in my master page (the OnInit method) which does a Response.Redirect, and it works fine. I check for an anonymous user using "Request.IsAuthenticated" instead of "Profile.IsAnonymous" - maybe that will help.

I'd make sure the exception is being raised by the Response.Redirect and not by the access of the Profile object using Profile.IsAnonymous. Put a try/catch around that and look at the stack trace to see exactly which line in your code raises the exception.

Hope that helps,

Donnie
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007

Web:
newbie: Works in webpage, but NOT in masterpage, why? - ASP.NET Forums newbie: Works in webpage, but NOT in masterpage, why? Last post 07-31-2006 1:00 PM by soccerdad. 4 replies. Sort Posts: ...
Newbie ? SEO for ASPX webpages - SitePoint Forums Newbie ? SEO for ASPX webpages Search Engine Optimization. ... I found that the site has a master page where I can put meta tag for the site ...
.NET ASP.NET 2 Questions about using AJAX with Master Page I'm afraid you've made the "classic" newbie misconception about MasterPages ... MasterPages are't frames. That's not how MasterPages work. ...
2 Questions about using AJAX with Master Page describing MasterPages but that was before AJAX so I don't know if he's done ... MasterPages are't frames. That's not how MasterPages work. ...
2 Questions about using AJAX with Master Page I'm afraid you've made the "classic" newbie misconception about MasterPages .... That's not how MasterPages work... -- Mark Rae ASP.NET MVP ...
Base Master Pages I've been looking for some classes to style but I can't find certain classes in this base master page. If not, can you show me where I should insert the ...
How to Dynamically add menu items to master page in ASP.NET 3.5 ... I'm a newbie to MVC - do you have a sample or pseudocode? ... Reason #7 NOT to use SlickEdit: "If I finish my work on time they'll just give me more. ...
CodeProject: MasterPages reinvented - a Component Based Template ... Take this one if eventing of controls does not work with OnLoad templating. ..... I'm sure this is a newbie question, but... I'm running the demo project, ...
MSDN SharePoint - Design and Customization Help a newbie ... We can customize, configure any of SharePoint webpage, masterpage, html page. ... not a WYSIWYG environment. So, a hybrid approach works really good. ...
TheMSsForum.com >> Asp >> MasterPage subdirectory and ResolveUrl ... Building webpages I am working on a web based asp.net 2.0 project that began as an application in Visual Studio 2005. The web site appears to work okay, but ...




Search This Site:










customizing the site navigation

cache master page

printer friendly page using a querystring in masterpage and pagelayouts

expanding menuitem with onmouseover

web.config global page values

error when using a user control within a content section tag

mailto: in a web.sitemap

login view problem

menus submenus

tree view behaviour

master pages and seo optimization

tree view database control - trying to select gridview primary key to return to tree view

print content section

block page by direct url

how do i style treeview control?

is it possible synchronize a treeview control after treeview data has been updated... without refreshing the page?

how to put the 'cascading' back into 'cascading style sheets'?

using frames and the menu control; any ideas?

setting a colour and a font for all text on a website

setting the master page static

looking for menu control style examples

alligning a grid view in master page

multiple sitemaps using the sqlsitemapprovider for different sections

how to tell when a particular page is loading?

using response.redirect causing error

expand a tree view parent node when node text is selected

web.sitemap + navigation control

multiple inheritence??

treeview with dropdown nodes

masterpages and modal dialog boxes.

  Privacy | Contact Us
All Times Are GMT