html - The resource cannot be found error on clicking a link -
i have html page. when click on link <a href="~/floorplan/userlabfloor">
on html page throws error "the resource cannot found" unable issue.
here html code (index.cshtml)
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"></button> </div> <!-- collect nav links, forms, , other content toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> </div> <!-- /.navbar-collapse --> </div> <!-- /.container --> </nav> <div class="container"> <div class="row"> <div class="col-lg-12"> <h1 class="page-header">dashboard</h1> </div> <!-- /.col-lg-12 --> </div> <!-- /.row --> <div class="row"> <div class="col-lg-3 col-md-6"> <div class="panel panel-red"> <div class="panel-heading"> <div class="row"> <div class="col-xs-3"> <i class="fa fa-ticket fa-5x"></i> </div> <div class="col-xs-9 text-right"> <div class="huge"><i class="fa fa-cog fa-spin"></i></div> <div>budget</div> </div> </div> </div> <a href="~/floorplan/userlabfloor"> <div class="panel-footer"> <span class="pull-left">view details</span> <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span> <div class="clearfix"></div> </div> </a> </div> </div> </div> <script src="scripts/jquery-1.10.2.js"></script> <script src="scripts/bootstrap.min.js"></script>
userlabfloor.cshtml:
@model ustglobal.workbench.ui.models.floorplanviewmodel @{ viewbag.title = "requestform"; } <div class="row"> <div class="col-lg-8"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="page-header">request form</h2> </div> </div> @using (html.beginform("userlabfloor", "floorplan")) { <div class="row"> <div class="col-lg-8"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-lg-4">period:</label> <div class="col-lg-8"> @html.dropdownlist("quarter", new selectlistitem[] { (new selectlistitem() { text = "q1", value = "1" }), (new selectlistitem() { text = "q2", value = "2" }), (new selectlistitem() { text = "q3", value = "3" }), (new selectlistitem() { text = "q4", value = "4" }) }, "-- select quarter --", new { @class = "form-control" }) <br /> @html.dropdownlist("year", new selectlistitem[] { (new selectlistitem() { text = "2016", value = "2016" }), (new selectlistitem() { text = "2017", value = "2017" }) }, "-- select year --", new { @class = "form-control" }) </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-lg-4">line id:</label> <div class="col-lg-8"> @html.textboxfor(model => model.floorconfig.lineid, new { onkeypress = "return isnumberkey(event)", @class = "form-control" }) </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-lg-4">project:</label> <div class="col-lg-8"> @html.textboxfor(model => model.floorconfig.project, new { onkeypress = "return isnumberkey(event)", @class = "form-control" }) </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-lg-4">budget:</label> <div class="col-lg-8"> @html.textboxfor(model => model.floorconfig.budget, new { onkeypress = "return isnumberkey(event)", @class = "form-control" }) </div> </div> </div> </div> </div> <div class="row"> <div class="col-lg-offset-4" style="padding: 10px 0px 0px 0px;"> <input type="submit" id="btnsubmit" value="submit" class="btn btn-lg btn-success" /> <input type="button" id="btncancel" value="clear" class="btn btn-lg btn-success" /> </div> </div> } </div> </div>
floorplancontroller.cs
[actionname("userlabfloor")] [httppost] public actionresult userlabfloor() { floorconfirguration floorconfig = new floorconfirguration(); floorservice.savelabfloorconfig(floorconfig); return view("userlabfloor"); }
as @nirman have mentioned you're missing handler in floorplancontroller.cs
.
you're returning userlabfloor
view after form submission (post) didn't have [httpget]
definition userlabfloor()
method.
this means browser issue request after post there's no matching route (404) in mvc routetable in case.
to understand more behaviour, please read https://en.wikipedia.org/wiki/post/redirect/get
Comments
Post a Comment