English 中文(简体)
ASP. NET MVC视觉演播室:当地东道方404个错误 不能找到资源。
原标题:ASP.NET MVC visual studio http 404 error on local host, The resource cannot be found.

I m fairly new to C# programming in Visual Studio 2017 and I am having issue with building my view page on local host. getting below error.

服务器/应用。

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: /Views/Random.cshtml

the home page loads on local host, it s the view page that does not. below what I have done so far and still not resolved the issue.

  1. In control pane > programmes >特恩多德视窗上或外面。 我在“因特网信息服务”(IIS 6)下打了所有箱子。

  2. 在我的视觉演播室项目中,房地产——改变了港口号码,与当地IIS进行了不同的开端,没有进行这些改动。

现在我几乎不忘其他事情。 我在网上寻求解决这一问题,并尝试了与我的问题有关的一切,但没有奏效。 至今已超过7小时,试图确定这一点

我遵循了在线课程,与我的课程辅导员订立完全相同的编码,对辅导员而不是对我进行罚款。

我的控制员在此编码:

示范网页:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Vidly.Models
{
    public class Movie
    {
        public int Id { get; set; }
        public string Name { get; set; }


    }
}

主计长:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Vidly.Models;

namespace Vidly.Controllers
{
    public class MoviesController : Controller
    {
        // GET: Movies
        public ActionResult Random()
        {
            var movie = new Movie() { Name = "Shrek!" };

            return View(movie);
        }
    }
}

view page (random):
@model Vidly.Models.Movie
@{
    ViewBag.Title = "Random";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@Model.Name</h2>
问题回答

What kind of project did you start with? In one of your config files you should see code defining your route template. Have you tried adding a debug point in the method to see if it s being hit when you navigate to /movies/random ?

routeTemplate: "/{controller}/{id}"
//or
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");

如果你选择错误的基础项目,你的道路可能有所不同。 i.e. 。 在此情况下,路线模板

你也可以尝试

    // GET: Movies
    [HttpGet]
    public ActionResult Random()
    {
        var movie = new Movie() { Name = "Shrek!" };

        return View(movie);
    }

当我试图追随辅导时,我就犯了同样的错误。 我在这里想到你错过一步。 不要右边点击VIEW,而是要打造。 Random.csthml, 您应首先扩大VIEW,并右边点击, 并在那里储存。 Random.cshtml 文档。 希望这一帮助





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签