简体   繁体   English

如何将新网页添加到ASP.NET MVC

[英]How to add a new webpage to ASP.NET MVC

Right now I am making a MVC that has a default page that loads up. 现在,我正在制作一个具有加载默认页面的MVC。 From this page, the user can press a button to go to the next page. 用户可以从该页面按一个按钮进入下一页。 So far, I have made the first page work and a button that goes to a specified URL for the second page. 到目前为止,我已经完成了第一页的工作,并且使第二页的按钮转到了指定的URL。 The only issue I am having is making the view that I want to correspond to the second page have the correct URL. 我唯一的问题是使要与第二页对应的视图具有正确的URL。

Here is the code for my button link to the next URL 这是我的按钮链接到下一个URL的代码

<input type="button" value="Create" onclick="location.href='@Url.Action("IndexA", "HomeController")'" />

I guess my question is how do I make my view have the specified URL that I want so it can be accessed? 我想我的问题是如何使我的视图具有所需的指定URL,以便可以对其进行访问?

I used something like this in my own project. 我在自己的项目中使用了类似的方法。

    @if (Request.UrlReferrer != null && Request.UrlReferrer.Host == Request.Url.Host)
    {
        <a href="@Request.UrlReferrer" class="dbtn btn-11">
            <i class="fa fa-undo"></i>
            @Resources._Action_Back
        </a>
    }

only came from within the domain that was published I said let the button appear. 我只说来自发布的域内的内容,让按钮出现。

there is something like add controller in default settings controller name + controller. 在默认设置中,控制器名称+控制器中有类似添加控制器的内容。 So just write the name there. 因此,只需在此处输入名称。

Please see this photo. 请看这张照片。 https://ibb.co/4SS5nYh https://ibb.co/4SS5nYh

You add a new controller and a new view for that new page (also a model). 您为该新页面(也是模型)添加一个新的控制器和一个新的视图。 I have called mine Test. 我打电话给我的测试。

Then in the button. 然后在按钮中。 you call them with url action. 您可以使用网址操作来称呼他们。

<input type="button" value="Create" onclick="location.href='@Url.Action("Index", "Test")'" />

我必须在URL.Action中放置“ home”而不是“ HomeController”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM