Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate an url from an action with viewmodel #32

Open
valeriob opened this issue Jul 25, 2017 · 2 comments
Open

How to generate an url from an action with viewmodel #32

valeriob opened this issue Jul 25, 2017 · 2 comments
Assignees
Milestone

Comments

@valeriob
Copy link

Hi,
given an action with a ViewModel parameter
public IActionResult Index(IndexViewModel model)
and a viewModel like this
public class IndexViewModel
{
public int MyProperty {get;set;}
}
i would like that
var url = Url.Action(r => r.Index(model));
generate
/Home/Index?MyProperty=5

How can i do that with TypedRouting ?
Thanks

@svickers
Copy link

I am wondering about this as well. This case doesn't appear to work:

public IActionResult Index(int n){ ... }

public IActionResult Redirect(){
    return this.RedirectToAction<HomeController>(a=>a.Index(1));
}

The RedirectToActionResult that is returned contains a null RouteValueDictionary. This works however, but it kinda negates the good part of having typed routing IMHO.

public IActionResult Redirect(){
    return this.RedirectToAction<HomeController>(a=>a.Index(With.No<int>()), new{n=1});
}

@ivaylokenov
Copy link
Owner

Hi, thank you for your issue. Since I am overwhelmed with my other project https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc, I did not have a lot of time to support this one. Will try to publish a new package during the weekend. Thank you for your patience!

@ivaylokenov ivaylokenov self-assigned this Sep 10, 2019
@ivaylokenov ivaylokenov added this to the Version 2.0.0 milestone Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants