TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dinesh Kudale
NA
127
18.1k
"The system cannot find the file specified." in asp.Net MVC
Jul 6 2018 4:34 AM
I have created asp.Net MVC application (code first approach). If I run Index.cshtml file, then it arises following error message in the browser.
"The system cannot find the file specified"
Error Shows in this line
Line 26: db.Standards.Add(standard1);
If it runs successfully, then it must create Database in App_Data folder. But this Index.cshtml is not running successfully. Please guide that how to resolve this problem.
In Visual Stusdio 2015->File->New->Project->Asp.Net Web Application, Name of Project:Note7Page55->Seelect MVC option->ok.
Model Folder->Student.cs
namespace
Note7Page55.Models
{
public
class
Student
{
public
int
StudentId {
get
;
set
; }
public
string
StudentName {
get
;
set
; }
public
string
Address {
get
;
set
; }
public
string
City {
get
;
set
; }
public
Standard Standard {
get
;
set
; }
}
}
Model Folder->Standard.cs
using
System.Collections.Generic;
namespace
Note7Page55.Models
{
public
class
Standard
{
public
int
StandardId {
get
;
set
; }
public
string
StandardName {
get
;
set
; }
public
ICollection<Student> Students {
get
;
set
; }
}
}
Model Folder->SchoolContext.cs
using
System.Data.Entity;
namespace
Note7Page55.Models
{
public
class
SchoolContext : DbContext
{
public
SchoolContext() :
base
(){}
public
DbSet<Standard> Standards {
get
;
set
; }
public
DbSet<Student> Students {
get
;
set
; }
}
}
Controller Folder-> SchoolController.cs
using
System.Web.Mvc;
using
Note7Page55.Models;
namespace
Note7Page55.Controllers
{
public
class
SchoolController : Controller
{
SchoolContext db =
new
SchoolContext();
// GET: School
public
ActionResult Index()
{
Standard standard1 =
new
Standard()
{
StandardName =
"Std. 5th"
};
Student student1 =
new
Student()
{
StudentName =
"Dinesh Kudale"
,
Address =
"Gar Fata"
,
City =
"Patas"
};
db.Standards.Add(standard1);
db.Students.Add(student1);
db.SaveChanges();
return
View();
}
}
}
Added View as Index.cshtml
@model Note7Page55.Models.Student
@{
ViewBag.Title =
"Index"
;
}
<h2>Index</h2>
When I run Index.cshtml file, then it arises following error message in the browser.
"The system cannot find the file specified"
Please guide that how to resolve this problem.
Reply
Answers (
4
)
Partial View replaces Parent view
session timeout