做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

Nancy之基于Nancy.Hosting.Self的小Demo_html/css

來源:懂視網 責編:小采 時間:2020-11-27 16:36:38
文檔

Nancy之基于Nancy.Hosting.Self的小Demo_html/css

Nancy之基于Nancy.Hosting.Self的小Demo_html/css_WEB-ITnose:今天來做個基于Nancy.Hosting.Self的小Demo。 關于Self Hosting Nancy,官方文檔的介紹如下 https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy 文檔具體的內容我就不一一翻譯了,主要是演示從頭到尾的一個過程,然后看看Nancy.Hosti
推薦度:
導讀Nancy之基于Nancy.Hosting.Self的小Demo_html/css_WEB-ITnose:今天來做個基于Nancy.Hosting.Self的小Demo。 關于Self Hosting Nancy,官方文檔的介紹如下 https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy 文檔具體的內容我就不一一翻譯了,主要是演示從頭到尾的一個過程,然后看看Nancy.Hosti

今天來做個基于Nancy.Hosting.Self的小Demo。

關于Self Hosting Nancy,官方文檔的介紹如下

https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy

文檔具體的內容我就不一一翻譯了,主要是演示從頭到尾的一個過程,然后看看Nancy.Hosting.Self的源碼

一、新建一個控制臺應用程序(Console Application)

二、通過NuGet添加我們需要的Nancy包

這里我們可以直接添加Nancy.Hosting.Self,添加這個會順帶添加Nancy。

到這里我們的基本工作就KO了。

三、打開Program.cs,開始寫代碼了

 1 class Program 2 { 3 static void Main(string[] args) 4 { 5 using (var nancySelfHost = new NancyHost(new Uri("http://localhost:8888/"))) 6 { 7 nancySelfHost.Start(); 8 Console.WriteLine("NancySelfHost已啟動。"); 9 try10 {11 Console.WriteLine("正在啟動 http://localhost:8888/ ");12 System.Diagnostics.Process.Start("http://localhost:8888/");13 Console.WriteLine("成功啟動 http://localhost:8888/ ");14 }15 catch (Exception)16 {17 }18 Console.Read();19 }20 Console.WriteLine("http://localhost:8888 已經停止 \n NancySelfHost已關閉。"); 21 }22 }Program.cs

這里實例化了一個新的NancyHosting,并直接用Process.Start打開了一個網頁。

這樣做是為了省時省力偷下懶,不用在啟動程序之后再手動去打開瀏覽器去輸入http://localhost:8888

如果不熟悉Process,可以看一下這個

https://msdn.microsoft.com/en-us/library/e8zac0ca(v=vs.110).aspx

四、新建一個Modules文件夾,用來存放我們的Modules

在Modules文件夾新建一個HomeModule.cs

1 public class HomeModule:NancyModule2 {3 public HomeModule()4 {5 Get["/"] = _ => "I'm from Nancy.Hosting.Self!";6 }7 } HomeModule.cs

運行一下,看看效果

正是我們要的結果。下面來看看視圖有沒有問題。

五、建一個Views文件夾,用于存放視圖

新建Home文件夾,新建index.html,這里我們就不用Razor了,Nancy支持多種視圖引擎!!這個很不錯。

 1 2  3  4  5 NancyDemo 6  7  8 

SelfHostingDemo

9 10 index.html

同時對HomeModule.cs進行修改

 1 public class HomeModule:NancyModule 2 { 3 public HomeModule() 4 { 5 Get["/"] = _ => 6 { 7 return View["index"]; 8 }; 9 10 }11 }HomeModule.cs

運行試試。oh no~~ 出錯了。。

為什么會出現錯誤呢?不應該啊!!

既然有錯誤,就要排除錯誤,看看它說那里有問題:

Nancy.RequestExecutionException: Oh noes! ---> Nancy.ViewEngines.ViewNotFoundException: Unable to locate view 'index'Currently available view engine extensions: sshtml,html,htmLocations inspected: views/Home/index-zh-CN,views/Home/index,Home/index-zh-CN,Home/index,views/index-zh-CN,views/index,index-zh-CN,indexRoot path: D:\GithubCode\Demos\NancyDemoWithSelfHosting\SelfHostingDemo\SelfHostingDemo\bin\DebugIf you were expecting raw data back, make sure you set the 'Accept'-header of the request to correct format, for example 'application/json'提示的居然是沒有找到視圖!!再細細看一下就會發現問題了。Root path!?。。∫晥D應該在放到Debug目錄下,這里建的是控制臺應用程序,不是web應用程序。所以就把Views文件夾搬家到Debug下面。運行看看,OK,成功了六、把這個demo放到linux下看看在 /var/www/ 下面新建一個文件夾 mkdir nancydemo將程序bin目錄下的文件傳到 /var/www/nancydemo 中,ls看一下里面的內容執行 mono SelfHostingDemo.exe看看效果,OK!到這里,已經完成了一個簡單的Demo了。趁著時間還早,看看Nancy.Hosting.Self的內部實現,源碼地址:https://github.com/NancyFx/Nancy/tree/master/src/Nancy.Hosting.Self還記得否?我們的Program.cs中有用到這個類----NancyHost
var nancySelfHost = new NancyHost(new Uri("http://localhost:8888/"))
細細看看這個類里面有什么東西。https://github.com/NancyFx/Nancy/blob/master/src/Nancy.Hosting.Self/NancyHost.cs

有六個重載,其實這六個重載都是為了初始化 NancyHost ,有三個是用了默認配置,有三個是用了自定義配置。

我們用到的NancyHost是采用的默認配置,參數就是一個可變的Uri數組。

然后看看Start 方法

主要是監聽我們的請求,這個監聽過程主要用到了HttpListener,還有異步回調。

里面的 Task.Factory.StartNew 可以看看msdn的介紹

https://msdn.microsoft.com/en-us/library/dd321439(v=vs.110).aspx

持續降溫。注意保暖。

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

Nancy之基于Nancy.Hosting.Self的小Demo_html/css

Nancy之基于Nancy.Hosting.Self的小Demo_html/css_WEB-ITnose:今天來做個基于Nancy.Hosting.Self的小Demo。 關于Self Hosting Nancy,官方文檔的介紹如下 https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy 文檔具體的內容我就不一一翻譯了,主要是演示從頭到尾的一個過程,然后看看Nancy.Hosti
推薦度:
標簽: html demo css
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 鹿邑县| 徐汇区| 贡山| 厦门市| 波密县| 大城县| 洪湖市| 呼图壁县| 浪卡子县| 福泉市| 子洲县| 诏安县| 青浦区| 吴忠市| 子长县| 纳雍县| 娄底市| 建宁县| 乌什县| 德令哈市| 浪卡子县| 谷城县| 西乌珠穆沁旗| 福建省| 滦平县| 海晏县| 雷州市| 兴义市| 新郑市| 梨树县| 永登县| 鲁山县| 安康市| 明水县| 华阴市| 兰考县| 砚山县| 无棣县| 顺义区| 惠来县| 卓资县|