2009-03-21 14 views
0

MVCフレームワークのRTW 1.0をインストールしました。私は過去にRC2を使ってチュートリアルを行っていました。私は今RC2で持っていなかった基本的なルーティングがうまくいかない問題があります。ASP .NET MVCのデフォルトルーティングの問題RTW 1.0

VS 2008で新しいMVCアプリケーションを作成した場合、ホームページのルーティングはそのままでは機能しません。

仕事や404エラーを与えていない、次ただし、何らかの理由

http://mydomain/ 
http://mydomain/Home/Index/1 

ため、次のURLの仕事。

http://mydomain/Home 
http://mydomain/Home/Index 

マイRegisterRoutes方法がデフォルトであり、この

public static void RegisterRoutes(RouteCollection routes) 
     { 
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

      routes.MapRoute(
       "Default",            // Route name 
       "{controller}/{action}/{id}",       // URL with parameters 
       new { controller = "Home", action = "Index", id = "" } // Parameter defaults 
      ); 

     } 

マイHomeController.csこの

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

namespace MyNamespace.Controllers 
{ 
    [HandleError] 
    public class HomeController : Controller 
    { 
     public ActionResult Index() 
     { 
      ViewData["Message"] = "Welcome to ASP.NET MVC!"; 

      return View(); 
     } 

     public ActionResult About() 
     { 
      return View(); 
     } 
    } 
} 

のように見えるとインデックスビューが生成されるだけで、デフォルトで

のように見えます
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server"> 
    Home Page 
</asp:Content> 

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> 
    <h2><%= Html.Encode(ViewData["Message"]) %></h2> 
    <p> 
     To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. 
    </p> 
</asp:Content> 

答えて

0

私は問題を追跡することができました。私は古いWebサイトプロジェクトでIIS 7でホストしていました。ファンキーな設定があったに違いない(これは統合モードに設定されている)。だから私がしたのは、新しいウェブサイトとアプリケーションプールを作成し、それは最初に行った:)時間がかかりました!