Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
T4MVC - sposób na stringi w aplikacji ASP.NET MVC
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", MVC.Home.About())</li>
<li>@Html.ActionLink("Contact", MVC.Home.Contact())</li>
</ul>
public virtual ActionResult Action(int id)
{
return Content(id.ToString());
}
public virtual ActionResult RedirectToActionUsingString()
{
return RedirectToAction("Action", "Home", new { id = 10 });
}
public virtual ActionResult RedirectToActionUsingT4MVC()
{
return RedirectToAction(MVC.Home.Action(10));
}
public virtual ActionResult UseViewNameAsString()
{
ViewBag.ActionName = "UseViewNameAsString";
return View("View");
}
public virtual ActionResult UseViewNameUsingT4MVC()
{
ViewBag.ActionName = ActionNames.UseViewNameUsingT4MVC; // MVC.Home.ActionNames.UseViewNameUsingT4MVC
return View(Views.View);
}
<div class="row">
<div class="col-md-12">
<img src="@Links.Content.Images.Visual_Studio_2013_Logo_svg_png" />
</div>
</div>
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "IndexRoute",
url: "Index",
defaults: MVC.Home.Index()
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment