gauri
gauri

Reputation: 11

Server Error in '/' Application

I am creating a webpage. The home page has sidebars and when you click on those sidebars they will navigate you to the next page. I am trying to navigate to the "invoice entry" page but the button isn't working. I get this error: Server Error in '/' Application.

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.

Requested URL: /Home/Invoice

Page name is Invoice Entry.

Codes in Invoice.asp are:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"    Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainbody" runat="server">

<form name="Invoice" method="post" action="<%=Url.Content("~/Home/Invoice")%>">

   <h2>Invoice</h2>

Codes in Site.Master are:

         <asp:ContentPlaceHolder ID="sidebar" runat="server">
         <ul>
         <li><a href="<%=Url.Content("~/Home/index")%>">Home Page</a>
         <li><a href="<%=Url.Content("~/Home/Hospital")%>">Patient Entry</a>
         <li><a href="<%=Url.Content("~/Home/Invoice")%>">Invoice Entry</a>
         </ul>

Upvotes: 0

Views: 686

Answers (4)

Srikanth Sri
Srikanth Sri

Reputation: 31

I also faced the same issue what you got but the solution that make my application to run is below:

sometimes we will make spelling mistakes while setting the path to in IIS,so please
once check out the application name.

Go to IIS-->on opening IIS you will observe the "connections" pane on left hand side,and in that
expand the root node until you will observe your application names,Here ONCE CHECK OUT THE NAMES YOU GIVEN CORRECTLY WITH YOUR APPLICATION PHYSICAL PATH IN SYSTEM.

Upvotes: 1

Alexander
Alexander

Reputation: 1297

First,y ou should not use Url.Content method for create links to you actions, instead use Url.Action for example:

  • Url.Action("Home") - this will getnerate link for "Home" action of the current controller
  • Url.Action("Home","Support") - this will getnerate link for "Home" action of the SupportController

Also you can use Html.ActionLink helper for generating markup, i.e.: Html.ActionLink("Go home","Home") - genarates <a href="url_to_home_action">Go home</a>

Second make sure that you have create method in your controller with corresponding name

public class HomeController:Controller 
{
    public ActionResult Invoice() //called if you navigate to /Home/Action
    {
    }
}

Upvotes: 0

Khaled Musaied
Khaled Musaied

Reputation: 2493

Make sure that you added a Method in HomeController class for each action (page)

 public class HomeController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Hospital()
        {
            return View();
        }
        public ActionResult Invoice()
        {
            return View();
        }

........
  }

also checkout Global.asax it should have the following code:

routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

Thats it :)

Upvotes: 0

Rob
Rob

Reputation: 4947

You should use file extensions in your url, not sure if this causes your problems tho..

url.Content("~/Home/Index.aspx")

Post some of your errors, its too vague ;P

Upvotes: 0

Related Questions