Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 24, 2010 02:36 AM by Bober Song - MSFT
Member
244 Points
489 Posts
Jul 02, 2010 02:59 PM|LINK
hi,
I am using the asp.net membership.
On my site I have a Profile.aspx page.
In the code behind of this page, i get the logged in UserId (Guid) and pass
this to a method in my DAL. GetUserByUserId()
In my database I have a Table called Member which the method gets the data from
and displays details on the page about the user.
What I want to happen is when they have logged in and are diverted to Profile.aspx,
the page URL shows www.MyWebSite/Profile/UsersName
for example
www.MyWebsite/Profile/JohnSmith.aspx
is this possible. In my Member table I have FirstName and LastName columns or do I get the
name from the membership table.
even better would be they go straight to www.MyWebsite/JohnSmith.aspx
thank you for any help
P
All-Star
34686 Points
2167 Posts
Jul 07, 2010 09:03 AM|LINK
Hi prontonet ,
From your description, I think you want to rewrite the user profile page.
You can create one Profile.aspx page, the page needs one parameter for getting user profile.
so you need to rewrite the Profile.aspx?username=JohnSmith to
Profile/JohnSmith.aspx
Please double check the following links which guide you to rewrite the Profile page url.
http://www.asp.net/learn/Videos/video-154.aspx http://www.codeproject.com/KB/aspnet/urlrewriter.aspx http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/ http://msdn.microsoft.com/en-us/library/ms972974.aspx http://www.urlrewriting.net/
I hope it is helpful to you.
Jul 08, 2010 12:47 PM|LINK
thanks for the response.
here is my code behind that sends the user to a profile page on clicking linkbutton on aspx.
protected void LinkButton2_Click(object sender, EventArgs e) { Guid MemberlId = (Guid)Membership.GetUser().ProviderUserKey;
string url = Request.ApplicationPath + "/Profile.aspx?Id=" + MemberId; Response.Redirect(url); }
On profile aspx, I have a data controls that show the Members profile by getting the GUID in the
query String and passing this to a method in my DAL such as GetMemberProfileByUserId(parmeter)
Instead of the page showing www.MyWebsite/Profile.aspx?Id9435953949349394394349343 with
the members GUID string I would rather the page shows
www. MyWebsite/Profile/JohnSmith.aspx
or
www. MyWebsite/JohnSmith.aspx
Thanks
Contributor
5014 Points
947 Posts
Jul 08, 2010 01:11 PM|LINK
A great article by Scott Mitchel on URL Rewriting might come to your help. Please check the "Creating Truly "Hackable" URLs" section in this
PAGE
Aug 23, 2010 05:13 PM|LINK
I am using the article you advised and it works but just have one question.
My web config is below
<RewriterConfig> <Rules> <!-- Rules for Product Lister --> <RewriterRule> <LookFor>~/JohnSmith\.aspx</LookFor> <SendTo>~/Members/Profile.aspx?Id=f7258f28-5920-4b9a-b1e5-4b8338fbb736</SendTo> </RewriterRule> </Rules> </RewriterConfig>
It only works if I put the full URL in like below with ".aspx extension"
www.mywebsite/JohnSmith.aspx
what I want to happen is it to work as below
www.mywebsite/johnsmith
Could you advise on this please?
thanks
Aug 24, 2010 02:36 AM|LINK
From your description, I think you need to use ne extension url rewriting. you need to configure the IIS. please double check the following links.
URL rewriting and no extentsion http://forums.asp.net/p/1412583/3106781.aspx#3106781 http://forums.asp.net/t/1426393.aspx
prontonet
Member
244 Points
489 Posts
Want to create Page URL rewrite based on Users GUID and Display name?
Jul 02, 2010 02:59 PM|LINK
hi,
I am using the asp.net membership.
On my site I have a Profile.aspx page.
In the code behind of this page, i get the logged in UserId (Guid) and pass
this to a method in my DAL. GetUserByUserId()
In my database I have a Table called Member which the method gets the data from
and displays details on the page about the user.
What I want to happen is when they have logged in and are diverted to Profile.aspx,
the page URL shows www.MyWebSite/Profile/UsersName
for example
www.MyWebsite/Profile/JohnSmith.aspx
is this possible. In my Member table I have FirstName and LastName columns or do I get the
name from the membership table.
even better would be they go straight to www.MyWebsite/JohnSmith.aspx
thank you for any help
P
Bober Song -...
All-Star
34686 Points
2167 Posts
Re: Want to create Page URL rewrite based on Users GUID and Display name?
Jul 07, 2010 09:03 AM|LINK
Hi prontonet ,
From your description, I think you want to rewrite the user profile page.
You can create one Profile.aspx page, the page needs one parameter for getting user profile.
so you need to rewrite the Profile.aspx?username=JohnSmith to
Profile/JohnSmith.aspx
Please double check the following links which guide you to rewrite the Profile page url.
http://www.asp.net/learn/Videos/video-154.aspx
http://www.codeproject.com/KB/aspnet/urlrewriter.aspx
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
http://msdn.microsoft.com/en-us/library/ms972974.aspx
http://www.urlrewriting.net/
I hope it is helpful to you.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
prontonet
Member
244 Points
489 Posts
Re: Want to create Page URL rewrite based on Users GUID and Display name?
Jul 08, 2010 12:47 PM|LINK
hi,
thanks for the response.
here is my code behind that sends the user to a profile page on clicking linkbutton on aspx.
protected void LinkButton2_Click(object sender, EventArgs e)
{
Guid MemberlId = (Guid)Membership.GetUser().ProviderUserKey;
string url = Request.ApplicationPath + "/Profile.aspx?Id=" + MemberId;
Response.Redirect(url);
}
On profile aspx, I have a data controls that show the Members profile by getting the GUID in the
query String and passing this to a method in my DAL such as GetMemberProfileByUserId(parmeter)
Instead of the page showing www.MyWebsite/Profile.aspx?Id9435953949349394394349343 with
the members GUID string I would rather the page shows
www. MyWebsite/Profile/JohnSmith.aspx
or
www. MyWebsite/JohnSmith.aspx
Thanks
P
sanjibsinha
Contributor
5014 Points
947 Posts
Re: Want to create Page URL rewrite based on Users GUID and Display name?
Jul 08, 2010 01:11 PM|LINK
A great article by Scott Mitchel on URL Rewriting might come to your help. Please check the "Creating Truly "Hackable" URLs" section in this
PAGE
12reach: asp.net meets php
prontonet
Member
244 Points
489 Posts
Re: Want to create Page URL rewrite based on Users GUID and Display name?
Aug 23, 2010 05:13 PM|LINK
hi,
I am using the article you advised and it works but just have one question.
My web config is below
<RewriterConfig>
<Rules>
<!-- Rules for Product Lister -->
<RewriterRule>
<LookFor>~/JohnSmith\.aspx</LookFor>
<SendTo>~/Members/Profile.aspx?Id=f7258f28-5920-4b9a-b1e5-4b8338fbb736</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
It only works if I put the full URL in like below with ".aspx extension"
www.mywebsite/JohnSmith.aspx
what I want to happen is it to work as below
www.mywebsite/johnsmith
Could you advise on this please?
thanks
Bober Song -...
All-Star
34686 Points
2167 Posts
Re: Want to create Page URL rewrite based on Users GUID and Display name?
Aug 24, 2010 02:36 AM|LINK
Hi prontonet ,
From your description, I think you need to use ne extension url rewriting. you need to configure the IIS. please double check the following links.
URL rewriting and no extentsion
http://forums.asp.net/p/1412583/3106781.aspx#3106781
http://forums.asp.net/t/1426393.aspx
I hope it is helpful to you.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework