Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7804557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:57:13+00:00 2026-06-02T01:57:13+00:00

We are using a friendly Name URL route scheme. Basically using a combination of

  • 0

We are using a friendly Name URL route scheme. Basically using a combination of the Principal Identity and a friendly name this can be mapped back to an identity internally (Person ID). So a route like this:

    routes.MapRoute(string.Empty, "{friendlyname}/Products/{action}", new {controller = "Products", action = "List"});

Would map to a URL like this:

    Adam/Products/List

This all works fine and abstracts away the internal Id of the named person which is required as well.

The problem is our Views are comprised of many partial views. When there are rendered by using the @Html.Action method they ultimately need the PersonID but from the URL we only have the ‘friendly name’.

I have thought about this for a while and there are two solutions to my mind:

  1. Pass the ‘friendly name’ into each of the controller action methods that return the partial views and internally the method will have to do a lookup on the currently logged in identity and the friendly name. This will give the PersonID to me and I can then efficiently query from then on. The only problem with this apporach is that due to the multiple partial views I will be querying on the currently logged in identity and friendly name for each partial view call which is innefficeint and I feel I should only have to write this code once.

  2. Somehow query in the view and get the PersonID so it can be passed to each @Html.Action call so the partial view controller methods will not have to do that lookup themselves saving round trips to the database for the same shared informtion. The problem with this is that I am not sure of a way of doing this cleanley in the view using the DI that we use through the rest of the application.

Any thoughts on approach to would be greatly appreciated.

Thank you,

Adam

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:57:15+00:00Added an answer on June 2, 2026 at 1:57 am

    You could add the Id to the session variables and access it from within the views with:

    @{var personId = int.Parse(Session["PersonId"])}
    

    Then you can pass it directly to partial views from the Parent without it hitting the client or having to pass parameters to any controllers.

    Update

    You could also access the session variable from the Controller if you wanted to do the work there instead without roundtripping to the database.

    EDIT

    If you put the property in a model and pass it to a page that post’s back then the model will not persist between posts.

    If for example your controller does:

    [HttpPost]
    public ActionResult DoSomething(ViewModel model)
    {
       if(ModelState.IsValid)
       {
           // Logic Here
       }
       return View(model)
    }
    

    when the page is reloaded, the model will have forgotten about the ID.

    There are a couple of ways around this. Either use @Html.HiddenFor(m => m.ID)
    which will put the property in the rendered HTML, which if it is truely a sensitive piece of information, is bad.

    Or you can rebuild the view model on each subsequent postback.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on a project where i am implementing a friendly url system using
I'm trying to make user friendly URL using mode rewrite. My problem is, that
this question is Basic but important. i need to rewrite php url using .htaccess
Im using the css friendly adapters from codeplex with sharepoint. It appears to be
I'm working on a mobile-friendly website using jQuery Mobile but would like to do
My situation is Using .NET 3.5 Using SDL.NET Need to make a friendly installer
I am doing some work with Web.Routing, using it to have friendly urls and
Hey, I'm making a simple user friendly css editor using Prototype. Anyway, I was
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
i am trying to use friendly url for my categories. Example Database cat_id |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.