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

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top