This project is read-only.

T4MVC Extension for Absolute URL. Is this possible?

Aug 29, 2012 at 10:58 AM
Edited Aug 29, 2012 at 10:58 AM
Hello,

I have the following T4MVC ActionResults:
  MVC.Home.Index();
  MVC.Post.Show(int id);
Is it possible to create a T4MVC extension that gets the absolute path?
  MVC.Home.Index().ToAbsolute();     // http://localhost:xxx/home

  MVC.Post.Show(2).ToAbsolute();   // http://localhost:xxx/post/show/4

Thank You,

Miguel
Aug 29, 2012 at 5:32 PM

See this post for the general MVC question. T4MVC has an equivalent overload of Url.Action.

Aug 29, 2012 at 5:41 PM
davidebbo wrote:

See this post for the general MVC question. T4MVC has an equivalent overload of Url.Action.

But in that case you need to specify the controller, the action, ...

I am looking for a extension way applied on the action result. So when using:

MVC.Post.Show(2).ToAbsolute(); 

I would get http://localhost:25715/post/show/2

So the extension would convert the ActionResult to what you suggest.

Is this possible?

Thank You,

Miguel

 

Aug 29, 2012 at 5:51 PM

Please see the Url.Action section in the doc to see how T4MVC is used.

Aug 29, 2012 at 8:26 PM
davidebbo wrote:

Please see the Url.Action section in the doc to see how T4MVC is used.

That is exactly what I was looking for.

Thank You,

Miguel

Feb 17, 2015 at 8:40 AM
I also want to create a full url, but the suggested solution using the url scheme does not work for me:
 @Html.Action(MVC.Main.Index(), Request.Url.Scheme) 
results in
http://mysite/ while it should be http://mysite/Main/Index.
In global asax default route is configured as :
routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Main", action="Index", id=UrlParameter.Optional })
Feb 17, 2015 at 3:35 PM
This is a very old thread, and the project is now on https://github.com/T4MVC/T4MVC. Can you please post there instead? Thanks!