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 4581126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:52:50+00:00 2026-05-21T20:52:50+00:00

as far as I understand a ModelBinder can generate class instances out of routedata/formdata

  • 0

as far as I understand a ModelBinder can generate class instances out of routedata/formdata.

What I’m looking for is a way to manipulate the data handed over to the view before it is consumed by the view.

What are the possiblities? Do I miss something obvious?

Thanks in advance!

EDIT
I don’t want to send clear IDs to the client but encrypt them (at least in edit cases). As it happens very often I want this step as much as possible automated.
I look for something like a ModelBinder or a Attribute to attach to a method/viewmodel/…

Example:
GET

public ActionResult Edit(int id)
{
    var vm = new EditArticleViewModel();

    ToViewModel(repository.Get<Article>(id), vm);

    return View(vm); // id is something like 5 and should be encryped before being used by the view
}

View

@model EditArticleViewModel

<div>
    @Html.HiddenFor(x => x.Id) <!-- x.Id should be encrypted, not just "5" -->
    ...
</div>

Lg
warappa

  • 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-05-21T20:52:51+00:00Added an answer on May 21, 2026 at 8:52 pm

    You could do something with an action filter:

    public class EncryptIDAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var vm = filterContext.Controller.ViewData.Model as EditArticleViewModel;
    
            if(vm != null)
            {
                vm.ID = SomeMethodToEncrypt(vm.ID);
            }
        }
    }
    

    and apply it to any relevent actions:

    [EncryptID]
    public ActionResult Edit(int id)
    {
        var vm = new EditArticleViewModel();
    
        ToViewModel(repository.Get<Article>(id), vm);
    
        return View(vm);
    }
    

    When the page is then posted you can use a model binder to decrypt the id.

    If you then wanted to apply this across multiple view models you could look at creating a custom data annotation which flags a property to be encrypted. In your action filter you can then look for any properties with this data annotation and encrypt them accordingly.

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

Sidebar

Related Questions

As far as I understand the serial port so far, transferring data is done
So far I can understand HTML.ActionLink and URL.RouteURL but still trying to absorb where
As far as I understand, in Scala we can define a function with no
As far as I understand, the IDeserializationCallback interface and the OnDeserialized event can both
As far as i understand ViewModel communicates with View via databinding. But how can
I understand so far that in Jquery, with html() function, we can convert HTML
As far as I understand, binding to a var in ActionScript is carried out
As far as I understand from the documentation the QUdpSocket are async but, still,
As far as I understand Facebook allowes you (through the API) to post on
As far as I understand, https is http plus SSL/TLS. What do I need

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.