2016-01-06 38 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 
}