Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
Created June 7, 2018 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielplawgo/08016083664e3ffadfe2f15da3a1a51c to your computer and use it in GitHub Desktop.
Save danielplawgo/08016083664e3ffadfe2f15da3a1a51c to your computer and use it in GitHub Desktop.
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