I think this is a URL routing question. I just created an MVC application on mac. I am trying to figure out how to link the pages. example, if I click on About or Contact nothing happens. In my _Layout.cshtml page when I added About.cshtml to this link after
href="About.cshtml" the application crashes.
This is what I see after clicking on About:
Application Exception
System.Web.HttpException
The resource cannot be found.
Description: HTTP 404.The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Details: No virtual path information available.
Exception stack trace:
at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache (System.Web.HttpContextBase context) [0x000cb] in <455c0c5cbc804c5abc3af7275091c0c5>:0
at System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache (System.Object sender, System.EventArgs e) [0x00016] in <455c0c5cbc804c5abc3af7275091c0c5>:0
at System.Web.HttpApplication+<RunHooks>d__217.MoveNext () [0x00158] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:1030
at System.Web.HttpApplication+<Pipeline>d__225.MoveNext () [0x0049f] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:1237
at System.Web.HttpApplication.Tick () [0x00000] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:927
Version Information: 5.2.0.224 (d15-3/14f2c81 Thu Aug 24 10:33:52 EDT 2017); ASP.NET Version: 4.0.30319.42000
Could somebody help please not sure what I am doing wrong or what I am suppose to do.
public ActionResult Login()
{
return RedirectToAction("ActionName", "ControllerName");
}
or
public ActionResult Login()
{
return Redirect("~/Home");
}
also try to check for the path. whether it is correct or not and you passed it correctly.
Regards
Deepak
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
I tried both code in Home controller but it's not working, I also try creating About controller and added your code that didn't work either. where should I check for the path? below is my home controller and about controller:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Ajax;
namespace Resetex.Controllers { publicclassHomeController : Controller { publicActionResult Index() { var mvcName = typeof(Controller).Assembly.GetName(); var isMono = Type.GetType("Mono.Runtime") != null;
<h2>Welcome to ASP.NET MVC @ViewData["Version"] on @ViewData["Runtime"]!</h2> <!-- Page Content --> <section class="content-section-a">
<div class="container"> <div class="row"> <div class="col-lg-5 ml-auto"> <hr class="section-heading-spacer"> <div class="clearfix"></div> <h2 class="section-heading">Death to the Stock Photo:<br>Special Thanks</h2> <p class="lead">A special thanks to <a target="_blank" href="http://join.deathtothestockphoto.com/">Death to the Stock Photo</a> for providing the photographs that you see in this template. Visit their website to become a member.</p> </div> <div class="col-lg-5 mr-auto"> <img class="img-fluid" src="Scripts/img/ipad.png" alt=""> </div> </div>
</div> <!-- /.container --> </section>
<section class="content-section-b">
<div class="container">
<div class="row"> <div class="col-lg-5 mr-auto order-lg-2"> <hr class="section-heading-spacer"> <div class="clearfix"></div> <h2 class="section-heading">3D Device Mockups<br>by PSDCovers</h2> <p class="lead">Turn your 2D designs into high quality, 3D product shots in seconds using free Photoshop actions by <a target="_blank" href="http://www.psdcovers.com/">PSDCovers</a>! Visit their website to download some of their awesome, free photoshop actions!</p> </div> <div class="col-lg-5 ml-auto order-lg-1"> <img class="img-fluid" src="Scripts/img/dog.png" alt=""> </div> </div>
</div> <!-- /.container -->
</section> <!-- /.content-section-b -->
<section class="content-section-a">
<div class="container">
<div class="row"> <div class="col-lg-5 ml-auto"> <hr class="section-heading-spacer"> <div class="clearfix"></div> <h2 class="section-heading">Google Web Fonts and<br>Font Awesome Icons</h2> <p class="lead">This template features the 'Lato' font, part of the <a target="_blank" href="http://www.google.com/fonts">Google Web Font library</a>, as well as <a target="_blank" href="http://fontawesome.io">icons from Font Awesome</a>.</p> </div> <div class="col-lg-5 mr-auto "> <img class="img-fluid" src="Scripts/img/phones.png" alt=""> </div> </div>
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
For some reason this didn't work either. I am using mac and the new visual studio for mac, I tried building just a simple web application on windows and everything works fine, I didn't have to do anything, I could add pages and just link them to the master
page. but on mac not sure what I am missing
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
4 Points
12 Posts
How to navigate to different pages on MVC application
Oct 09, 2017 05:10 PM|matthias22|LINK
I think this is a URL routing question. I just created an MVC application on mac. I am trying to figure out how to link the pages. example, if I click on About or Contact nothing happens. In my _Layout.cshtml page when I added About.cshtml to this link after href="About.cshtml" the application crashes.
This is what I see after clicking on About:
Application Exception
System.Web.HttpException
The resource cannot be found.
Description: HTTP 404.The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Details: No virtual path information available.
Exception stack trace:
at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache (System.Web.HttpContextBase context) [0x000cb] in <455c0c5cbc804c5abc3af7275091c0c5>:0
at System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache (System.Object sender, System.EventArgs e) [0x00016] in <455c0c5cbc804c5abc3af7275091c0c5>:0
at System.Web.HttpApplication+<RunHooks>d__217.MoveNext () [0x00158] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:1030
at System.Web.HttpApplication+<Pipeline>d__225.MoveNext () [0x0049f] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:1237
at System.Web.HttpApplication.Tick () [0x00000] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/System.Web/System.Web/HttpApplication.cs:927
Version Information: 5.2.0.224 (d15-3/14f2c81 Thu Aug 24 10:33:52 EDT 2017); ASP.NET Version: 4.0.30319.42000
Could somebody help please not sure what I am doing wrong or what I am suppose to do.
Thank you
Contributor
2990 Points
1210 Posts
Re: How to navigate to different pages on MVC application
Oct 10, 2017 02:33 AM|Deepak Panchal|LINK
Hi matthias22,
you can try to do something like below.
or
also try to check for the path. whether it is correct or not and you passed it correctly.
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
4 Points
12 Posts
Re: How to navigate to different pages on MVC application
Oct 10, 2017 04:32 PM|matthias22|LINK
Hi Deepak,
I tried both code in Home controller but it's not working, I also try creating About controller and added your code that didn't work either. where should I check for the path? below is my home controller and about controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
namespace Resetex.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
var mvcName = typeof(Controller).Assembly.GetName();
var isMono = Type.GetType("Mono.Runtime") != null;
ViewData["Version"] = mvcName.Version.Major + "." + mvcName.Version.Minor;
ViewData["Runtime"] = isMono ? "Mono" : ".NET";
return View();
}
public ActionResult About()
{
/* return RedirectToAction("About.cshtml", "HomeController");*/
return Redirect("~/About");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Resetex.Controllers
{
public class AboutController : Controller
{
public ActionResult About()
{
/* return RedirectToAction("About.cshtml", "AboutController");*/
return Redirect("~/About.cshtml");
}
}
}
Member
4 Points
12 Posts
Re: How to navigate to different pages on MVC application
Oct 10, 2017 04:39 PM|matthias22|LINK
Also here is my _Layout.cshtml and Index.cshtml:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Home</title>
<!-- Bootstrap core CSS -->
<link href="Scripts/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template -->
<link href="Scripts/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<!-- Custom styles for this template -->
<link href="Scripts/css/landing-page.css" rel="stylesheet">
</head>
<!--<head>
<title>@ViewBag.Title</title>
</head>-->
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Welcome To Resetex!</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="About.cshtml">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
<!-- Header -->
<header class="intro-header">
<div class="container">
<div class="intro-message">
<h1>Resetex Solution</h1>
<h3>Optimize solutions architect</h3>
<hr class="intro-divider">
<ul class="list-inline intro-social-buttons">
<li class="list-inline-item">
<a href="#" class="btn btn-secondary btn-lg">
<i class="fa fa-twitter fa-fw"></i>
<span class="network-name">Twitter</span>
</a>
</li>
<li class="list-inline-item">
<a href="#" class="btn btn-secondary btn-lg">
<i class="fa fa-github fa-fw"></i>
<span class="network-name">Github</span>
</a>
</li>
<li class="list-inline-item">
<a href="#" class="btn btn-secondary btn-lg">
<i class="fa fa-linkedin fa-fw"></i>
<span class="network-name">Linkedin</span>
</a>
</li>
</ul>
</div>
</div>
</header>
@RenderBody()
<!-- Footer -->
<footer>
<div class="container">
<ul class="list-inline">
<li class="list-inline-item">
<a href="#">Home</a>
</li>
<li class="footer-menu-divider list-inline-item">⋅</li>
<li class="list-inline-item">
<a href="#about">About</a>
</li>
<li class="footer-menu-divider list-inline-item">⋅</li>
<li class="list-inline-item">
<a href="#services">Services</a>
</li>
<li class="footer-menu-divider list-inline-item">⋅</li>
<li class="list-inline-item">
<a href="#contact">Contact</a>
</li>
</ul>
<p class="copyright text-muted small">Copyright © Your Company 2017. All Rights Reserved</p>
</div>
</footer>
<!-- Bootstrap core JavaScript -->
<script src="Scripts/vendor/jquery/jquery.min.js"></script>
<script src="Scripts/vendor/popper/popper.min.js"></script>
<script src="Scripts/vendor/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
...............
<h2>Welcome to ASP.NET MVC @ViewData["Version"] on @ViewData["Runtime"]!</h2>
<!-- Page Content -->
<section class="content-section-a">
<div class="container">
<div class="row">
<div class="col-lg-5 ml-auto">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">Death to the Stock Photo:<br>Special Thanks</h2>
<p class="lead">A special thanks to
<a target="_blank" href="http://join.deathtothestockphoto.com/">Death to the Stock Photo</a>
for providing the photographs that you see in this template. Visit their website to become a member.</p>
</div>
<div class="col-lg-5 mr-auto">
<img class="img-fluid" src="Scripts/img/ipad.png" alt="">
</div>
</div>
</div>
<!-- /.container -->
</section>
<section class="content-section-b">
<div class="container">
<div class="row">
<div class="col-lg-5 mr-auto order-lg-2">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">3D Device Mockups<br>by PSDCovers</h2>
<p class="lead">Turn your 2D designs into high quality, 3D product shots in seconds using free Photoshop actions by
<a target="_blank" href="http://www.psdcovers.com/">PSDCovers</a>! Visit their website to download some of their awesome, free photoshop actions!</p>
</div>
<div class="col-lg-5 ml-auto order-lg-1">
<img class="img-fluid" src="Scripts/img/dog.png" alt="">
</div>
</div>
</div>
<!-- /.container -->
</section>
<!-- /.content-section-b -->
<section class="content-section-a">
<div class="container">
<div class="row">
<div class="col-lg-5 ml-auto">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">Google Web Fonts and<br>Font Awesome Icons</h2>
<p class="lead">This template features the 'Lato' font, part of the
<a target="_blank" href="http://www.google.com/fonts">Google Web Font library</a>, as well as
<a target="_blank" href="http://fontawesome.io">icons from Font Awesome</a>.</p>
</div>
<div class="col-lg-5 mr-auto ">
<img class="img-fluid" src="Scripts/img/phones.png" alt="">
</div>
</div>
</div>
<!-- /.container -->
</section>
<!-- /.content-section-a -->
<aside class="banner">
<div class="container">
<div class="row">
<div class="col-lg-6 my-auto">
<h2>Connect to Start Bootstrap:</h2>
</div>
<div class="col-lg-6 my-auto">
<ul class="list-inline banner-social-buttons">
<li class="list-inline-item">
<a href="#" class="btn btn-secondary btn-lg">
<i class="fa fa-twitter fa-fw"></i>
<span class="network-name">Twitter</span>
</a>
</li>
<li class="list-inline-item">
<a href="#" class="btn btn-secondary btn-lg">
<i class="fa fa-github fa-fw"></i>
<span class="network-name">Github</span>
</a>
</li>
<li class="list-inline-item">
<a href="#" class="btn btn-secondary btn-lg">
<i class="fa fa-linkedin fa-fw"></i>
<span class="network-name">Linkedin</span>
</a>
</li>
</ul>
</div>
</div>
</div>
<!-- /.container -->
</aside>
<!-- /.banner -->
Contributor
2990 Points
1210 Posts
Re: How to navigate to different pages on MVC application
Oct 16, 2017 08:37 AM|Deepak Panchal|LINK
Hi matthias22,
try to use code like below.
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
4 Points
12 Posts
Re: How to navigate to different pages on MVC application
Oct 23, 2017 04:06 PM|matthias22|LINK
For some reason this didn't work either. I am using mac and the new visual studio for mac, I tried building just a simple web application on windows and everything works fine, I didn't have to do anything, I could add pages and just link them to the master page. but on mac not sure what I am missing
Contributor
2990 Points
1210 Posts
Re: How to navigate to different pages on MVC application
Oct 24, 2017 02:04 AM|Deepak Panchal|LINK
Hi matthias22,
I can see that with Windows everything is works correctly but you have issue with Mac.
above all examples are for windows. because till now we don't know that you are using Mac.
I you are trying to set hyperlink or path like windows then it will not work in Mac.
you need to set the path like Mac supports.
in Mac you need to set path in below format.
which is different then the windows.
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.