Sait
Sait

Reputation: 19815

ASP.NET Page naming using master pages

I have two user types: Readers and Authors. And I'm using Reader.Master and Author.Master for authorization purposes.

Then, there are StoriesR.aspx inherited from Reader.Master and StoriesA.aspx inherited from Author.Master. (In StoriesR.aspx page, you able to read the stories and in StoriesA.aspx you able to write the story.) So,

  1. Reader.Master --> StoriesR.aspx
  2. Author.Master --> StoriesA.aspx

Now, the thing is I don't want my users to see StoriesR.aspx?s=3 or StoriesA.aspx?s=3 in their browsers. I only want them to see stories?s=3. (even without the .aspx part)

How can I achieve this?

Upvotes: 1

Views: 116

Answers (2)

mmpatel009
mmpatel009

Reputation: 941

you can do this using urlMappings from web.config file

add in web.confing

<system.web>
    <!-- 
        Set compilation debug="true" to insert debugging 
        symbols into the compiled page. Because this 
        affects performance, set this value to true only 
        during development.
    -->
    <urlMappings enabled="true">
        <add url="~/reader/stories" mappedUrl="~/reader/StoriesR.aspx"/>
        <add url="~/author/stories" mappedUrl="~/author/StoriesA.aspx"/>

This will do url mapping.

Upvotes: 2

Jack Pettinger
Jack Pettinger

Reputation: 2755

You could have one aspx page and change the master page programmatically depending on what type of user they are, Author or Reader.

You can do this in the Page_PreInit event of your aspx page.

Check this c# example or this VB example

Upvotes: 1

Related Questions