HTTp 404 the resource your looking for (or one of its dependencies
hi i created new application in mvc2 asp and i run my application the following error are generate how to resolve this problem my url is http://localh开发者_StackOverflowost:2620/asset/details/8
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.
The problem you have is that there is no asset with the ID of 8.
What you need to do is either create an asset with the id of 8, or better still, show a meaningful message to the user.
public ActionResult Details(int id)
{
//Assuming you are using the repository pattern
Asset asset = assetRepository.GetAsset(id);
if (asset == null)
return View("NotFound");
else
return View(asset);
}
After that create a view called 'NotFound' within the asset view directory, that tells the user a meaningful message
See the NerdDinner Tutorials for lots of great assistance for people new to MVC2
精彩评论