How to alter Membership DefaultURL in Code Behind..

Hi,

I have some cbh code which invokes the relevant start page as defined by defaultURL in Web.config.

<forms name=".ASPXFORMSAUTH" defaultUrl=AppStart.aspx" loginUrl="Login.aspx"/>

using

FormsAuthentication.RedirectFromLoginPage(currentUserName, Login1.RememberMeSet)

However on certain situations I want to redirect to another login page. I had expected to reassign the defaultURL value in the CBH ie

FormsAuthentication.defaultURL = "MyOtherLogin.aspx"
FormsAuthentication.RedirectFromLoginPage(currentUserName, Login1.RememberMeSet)

But this does not work since defaultURL is readonly.

Is it possible to do this and if so how?

Thanks,

Sam
SamJollyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SamJollyAuthor Commented:
???? Explain please...... A bit too cryptic I am afraid...

What code should I use in the CBH..

Thanks,

Sam
0
SamJollyAuthor Commented:
Hi,

I have now sorted this.... So no further action required on this apart from closing. No points I am afraid due to no solution.

Sam
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

David RobitailleAnalyst ProgrammerCommented:
The solution I found for myself is to redirect the user within the page load of the "default login".

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
If Not Page.IsPostBack Then
    'here i test a condition, it could be a session variable or something like that  
    If something then
         Response.Redirect("~/login2.aspx")
    End If
End If 
End Sub 

Open in new window

0
SamJollyAuthor Commented:
Thanks for the input.... Since you spent the time and extended my knowledge you can have the points....

thnx,

Sam
0
SamJollyAuthor Commented:
thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.