2016-01-06 80 views
-1

我是mvc的新手,我需要创建一个应用程序,以便用户使用2个URL之一。一个url将直接指向一个通用注册,另一个指向一个定制的用户配置文件更新页面。 (在一个网站中,这将在page_load方法中。)在mvc应用程序中写入此逻辑的正确位置在哪里?MVC - 基于url的路由条目

+1

MVC版本?看看这里: http://www.codeproject.com/Articles/785710/An-Absolute-Beginners-Tutorial-for-Understanding-A和 http://www.webdevelopmenthelp.net/2014/03/routing -in-asp-net-mvc.html – blfuentes

+1

我觉得你甚至没有在Visual Studio中创建示例mvc应用程序,因为它完全是这样做的。请阅读并尝试asp.net mvc。 –

+0

我确实创建了示例mvc应用程序。但我不清楚这是怎么发生的。 @blacai的链接非常有帮助。 – coding

回答

0

在你WhateverController,你必须创建2种方法:

public ActionResult GenericRegistration() 

public ActionResult ProfilPage(int profilID) 

所以,你有2个网址:/不管/ GenericRegistration和随时/ ProfilPage/{ID}

此外,您可以创建另一个ProfilPage方法,当用户更新其数据时,您可以从HTML表单接受POST操作:

[HttpPost] 
public ActionResult ProfilPage(MyFormModel formModel) 
{ 
    // update user profile 
}