[英]C# WinForms Online Publishing and URL Parameters
嗨,我需要有關C#WinForms的一些信息。
我搜索了將URL參數傳遞給WinForm應用程序的文檔或一些第一步提示。
當我以聯機模式在Visual Studio中發布WinForms應用程序時(發布>安裝模式和配置>聯機)
在“清單”部分的“選項”對話框中,是一個復選框,用於允許將URL參數傳遞給應用程序。
我的問題是如何在應用程序中傳遞和獲取那些參數。
通常,我在Google上找到了我需要的東西....但是這次我什至沒有尋找什么。
很抱歉,但是我不是母語為英語的講者/作家,我使用的是Visual Studio初創版,所以我不確定上述選項是否正確拼寫;)
似乎您正在尋找ApplicationDeployment.CurrentDeployment.ActivationUri.Query
。
Microsoft的示例 :
using System.Web;
using System.Collections.Specialized;
using System.Deployment.Application;
...
private NameValueCollection GetQueryStringParameters()
{
NameValueCollection nameValueTable = new NameValueCollection();
if (ApplicationDeployment.IsNetworkDeployed)
{
string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
nameValueTable = HttpUtility.ParseQueryString(queryString);
}
return (nameValueTable);
}
在上面的鏈接中,還描述了如何傳遞這些參數:
查詢字符串是URL中以問號(?)開頭的部分,該問號以name = value的形式包含任意信息。 假設您有一個名為WindowsApp1的ClickOnce應用程序,該應用程序承載在服務器名上,並且您希望在應用程序啟動時傳遞變量username的值。 您的URL可能如下所示: http://servername/WindowsApp1.application?username = joeuser
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.