2012-02-14 58 views
2

路由我已經創建和主機nvc3 Web應用程序 現在的問題是,當我打開的MVC Web應用程序MVC3 Web應用程序直接在index.cshtml

,但我不我www.abc.com 它是開放index.cshtml IE主頁希望這樣的開放當我打開www.abc.com 我稱之爲一個靜態頁面index.htm應在MVC3 Global.asax中代碼開放的第一

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 = UrlParameter.Optional } // Parameter defaults 
      ); 

     } 

如何渲染到http://www.abc.com/mypage.html? 我該怎麼幫忙。

+0

ashuthinks - 我不認爲你的想法是一個靜態頁面作爲着陸頁是一個好主意。這是爲什麼。你所有在該頁面的鏈接都將被硬編碼,這意味着對域名的任何更改都必須經過仔細考慮(超過任何mvc路由問題)。我認爲爲什麼你需要靜態頁面的額外descritption可能有助於提供替代解決方案 – 2012-02-14 10:55:35

+0

嗨吉姆它只是暫時的時間,因爲我想顯示網站正在建設頁面。 – Neo 2012-02-14 11:23:56

+0

啊 - 這會有很大的不同。那麼你是否說這將是這個階段唯一顯示的頁面? – 2012-02-14 11:38:32

回答

2

ashuthinks,

根據您對該問題的修改意見。如果您只想顯示「Under contruction」類型的頁面,但沒有鏈接,則可以修改web.config並添加app_offline.htm文件。這裏的這些變化將是什麼樣子:

的web.config(梗概):

<?xml version="1.0"?> 
<configuration> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 
</configuration> 

app_offline.htm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head> 
<title>Your site title</title> 
</head> 
<body> 
    <div> 
    <span>Your Company name</span> 
    <h1>Sorry, server maintenance in progress </h1> 
    <h2>Please contact <a href="mailto:[email protected]">John Doe</a> on 000 123 456789 for further information</h2> 
    </div> 
</body> 
</html> 

,當你需要把現場直播,只需重命名上面的文件到web.config_offlineapp_offline.htm_offline,並使您的'正常'web.config發揮作用。當然,有許多方法可以對這隻貓進行皮膚處理,但是這對於我以前的項目非常有效。

看到:

http://weblogs.asp.net/scottgu/archive/2006/04/09/442332.aspx

進一步的細節。

+0

完美我在找這個謝謝你:) – Neo 2012-02-14 11:56:22

+0

沒問題,現在一切順利.. – 2012-02-14 12:00:30

相關問題