iT邦幫忙

0

專案轉移問題

YJ 2021-06-17 10:20:29745 瀏覽
  • 分享至 

  • xImage

有一份專案近期想轉移原本的主機系統,但把專案移至他台電腦測試發佈卻失敗,想請問是哪個地方需做修改呢https://ithelp.ithome.com.tw/upload/images/20210617/201312911caKfUuY4a.png
https://ithelp.ithome.com.tw/upload/images/20210617/201312916iid0VlXCz.png

看更多先前的討論...收起先前的討論...
有Default.aspx/htm檔嗎?
YJ iT邦新手 5 級 ‧ 2021-06-17 10:39:56 檢舉
沒有看到有這份耶
試試做個空的Default.aspx 或 htm 再debug,如果正常,就代表你的iis express是要求default頁面

(或index.aspx / htm)
YJ iT邦新手 5 級 ‧ 2021-06-17 11:30:19 檢舉
謝謝,我剛試做一個空的Default.aspx,跑出來正常空白頁面,那我這樣要如何做修改呢
首頁是哪個檔案?比如 test.aspx

那你在Default.aspx.cs 裡做個
Response.Redirect("test.aspx"); 轉址過去就好了
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2021-06-17 11:12:39

這篇的錯誤訊息跟你的一樣
不妨參考看看

YJ iT邦新手 5 級 ‧ 2021-06-17 11:28:52 檢舉

謝謝,這份我參考過囉,設定都已開啟,也都做過重新安裝,但還是出現錯誤/images/emoticon/emoticon06.gif

0
japhenchen
iT邦超人 1 級 ‧ 2021-06-17 13:06:10

首頁是哪個檔案?比如 test.aspx

那你在Default.aspx.cs 裡做個
Response.Redirect("test.aspx");
轉址過去就好了

看更多先前的回應...收起先前的回應...
YJ iT邦新手 5 級 ‧ 2021-06-17 13:19:27 檢舉

不好意思檔案是放在Views/Home/index.cshtml這樣也是直接導進去嗎https://ithelp.ithome.com.tw/upload/images/20210617/20131291HtkbeWv5cL.png
不知是不是這樣

放在load裡就對了
https://ithelp.ithome.com.tw/upload/images/20210617/20117954ROwF3Cw0xU.jpg

YJ iT邦新手 5 級 ‧ 2021-06-17 13:47:51 檢舉

https://ithelp.ithome.com.tw/upload/images/20210617/201312918hmqEjzSKh.png
我這邊導向不過去耶https://ithelp.ithome.com.tw/upload/images/20210617/201312910WdC7J9qYl.png

index不是資料夾吧?那你應該寫
Rsponse.Redirect("Hone/index.aspx");

YJ iT邦新手 5 級 ‧ 2021-06-17 14:14:22 檢舉

是index.cshtml耶

一樣自己改一下....
Response.Redirect("Home/index.cshtml");

YJ iT邦新手 5 級 ‧ 2021-06-17 14:19:17 檢舉

有的我剛試過了一樣導不過去耶/images/emoticon/emoticon02.gif

怎麼覺得你的 cs 碼跟我的不一樣?把Default.aspx刪除,重新新增,內容不要改,直接在Page_Load裡加redirect....

YJ iT邦新手 5 級 ‧ 2021-06-17 15:33:23 檢舉

https://ithelp.ithome.com.tw/upload/images/20210617/20131291cDdH4G23iE.png
我刪掉重改過了但問題跑到與一開始一樣
https://ithelp.ithome.com.tw/upload/images/20210617/20131291BQDyK0AG7x.png

iis express 設定條件跟iis7/8/9不太一樣...

先確定一下你的主頁是放哪個資料夾下的哪個檔案

YJ iT邦新手 5 級 ‧ 2021-06-17 17:00:36 檢舉

目前確定是放在Views/Home/index裡面

Views/Home/index裡的哪個網頁檔??

YJ iT邦新手 5 級 ‧ 2021-06-17 17:06:54 檢舉

https://ithelp.ithome.com.tw/upload/images/20210617/20131291ZLCkBodN2C.png

找到你網頁專案的根目錄裡的web.config檔,加入cshtml檔的支援

內容應該跟下方有點不同,但你找一下應有個 webpages:Enabled 的 value 看看是不是"true",如果不是,請改成true

<appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />  <-- 這行,請改成true
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
YJ iT邦新手 5 級 ‧ 2021-06-18 09:39:55 檢舉

謝謝,我把它改true了但問題還是一樣呦/images/emoticon/emoticon02.gif

1、找到你電腦上的applicationhost.config檔,一般是放在你的網頁專案本地資料夾中的 .vs/config 裡
2、用文字編輯器(建議裝vscode,好用+1,免費的)打開這個applicationhost.config檔,找到你的網站設定,如

 <site name="G4.Admin(1)" id="8">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Projetos\PortalG4\src\G4.Admin" />
                    <virtualDirectory path="/Offices/Edit" physicalPath="C:\Projetos\PortalG4\src" />
                    <virtualDirectory path="/Offices" physicalPath="C:\Projetos\PortalG4" />
                </application>
                <application path="/Offices/Edit/2" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Projetos\PortalG4\src\G4.Admin" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:6920:localhost" />
                </bindings>
            </site>

3、上面那串設定,刪掉(記得把這個config檔備份後再刪那段設定文字),存檔,用VS再開專案再按F5進DEBUG

YJ iT邦新手 5 級 ‧ 2021-06-18 14:23:06 檢舉

感謝,還是失敗/images/emoticon/emoticon20.gif

好吧,iis.express對cshtml的支援真的是讓人無語

試一下這篇
https://rayrrr.blogspot.com/2020/04/aspnet-mvc-mvc.html

YJ iT邦新手 5 級 ‧ 2021-06-18 14:33:01 檢舉

非常感謝您,我有用這台有寫過netcore專案發佈都是正常的,但這份移過來的專案卻開不起來/images/emoticon/emoticon02.gif

就MCV我也沒招了

YJ iT邦新手 5 級 ‧ 2021-06-18 17:05:23 檢舉

好的非常感謝您我在爬文試試/images/emoticon/emoticon20.gif

我要發表回答

立即登入回答