开发者

what is wrong? please see the below coding

using System.Web;
using System.Web.Mvc;

namespace MvcApplication2.Controllers
{
    public 开发者_开发技巧class PersonController : Controller
    {
        //
        // GET: /Person/

      //string fname { get; set; }
      //string lname { get;  set; }

        public string  Index()
        {

          return "This is the first";

        }

        public string welcome()
        {
            return "welcome";

        }

    }
}

i have created a personcontroller and wrote the above coding. when i run the program it alwasy give the asp.net mvc2 default page. how can i set my personcontroller as my start page ?


You need to change the routes in your Global.asax.cs. You will need a route like this if you want the index action to the be the default route.

routes.MapRoute(
   "Web.Default",
   "{controller}/{action}/{id}",
   new { controller = "Person", action = "Index", id = "" });

If you want the default action to be welcome then you can use this.

routes.MapRoute(
   "Web.Default",
   "{controller}/{action}/{id}",
   new { controller = "Person", action = "welcome", id = "" });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜