本文整理汇总了C#中UriBuilder.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UriBuilder.ToString方法的具体用法?C# UriBuilder.ToString怎么用?C# UriBuilder.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UriBuilder
的用法示例。
在下文中一共展示了UriBuilder.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string remoteIP = Request.ServerVariables["remote_addr"];
string allowedIP = System.Configuration.ConfigurationSettings.AppSettings["AdminIPAddress"];
if (remoteIP != allowedIP)
{
LocalConfiguration.Visible = false;
}
PageTitle.Text = ConfigurationManager.AppSettings["network"] + " Web Service";
Page.Title = PageTitle.Text;
// use UriBuilder to make a valid URL
UriBuilder wsdl = new UriBuilder();
wsdl.Scheme = Request.Url.Scheme;
wsdl.Host = Request.Url.DnsSafeHost;
/* UriBuilder is not aware of standard ports
* if a port is added, then it will display
* Co-PI say port :80 is not needed.
* so below handles standard port cases
*/
if (Request.Url.Scheme =="http") {
if ( !(Request.Url.Port==80) ) wsdl.Port = Request.Url.Port;
}
else if (Request.Url.Scheme == "https")
{
if ( !(Request.Url.Port == 443)) wsdl.Port = Request.Url.Port;
} else
{
wsdl.Port = Request.Url.Port;
}
serviceLocation.NavigateUrl = "~/" + ConfigurationManager.AppSettings["asmxPage"];
wsdl.Path = serviceLocation.ResolveUrl(ConfigurationManager.AppSettings["asmxPage"]) ;
serviceLocation.Text = wsdl.ToString();
serviceLocation_1_1.NavigateUrl = "~/" + ConfigurationManager.AppSettings["asmxPage_1_1"];
wsdl.Path = serviceLocation.ResolveUrl( serviceLocation_1_1.NavigateUrl);
serviceLocation_1_1.Text = wsdl.ToString();
Boolean OdGetValues = Boolean.Parse(ConfigurationManager.AppSettings["UseODForValues"]);
if (!OdGetValues)
{
//HyperLinkGetValuesObject.Enabled = false;
//HyperLinkGetValuesObject.Text = HyperLinkGetValuesObject.Text + " External or not implemented";
//HyperLinkGetValues.Enabled = false;
//HyperLinkGetValues.Text = HyperLinkGetValues.Text + " External or not implemented";
}
wsversion.Text = String.Format("Compile Date (UTC) {0}", AssemblyVersion);
}
示例2: btnApply_Click
/// <summary>
/// Apply the changes and remain on this page
/// </summary>
public void btnApply_Click(object sender, System.EventArgs e)
{
if (SaveData())
{
//
// Redirect back to this page in Edit mode
//
if (DataEntryMode == PageDataEntryMode.AddRow)
{
UriBuilder EditUri = new UriBuilder(Request.Url);
EditUri.Query += string.Format("{0}={1}", "szh_id", m_szh_idCurrent);
//
// Redirect back to this page
// with the primary key information in the query string
//
Response.Redirect(EditUri.ToString());
}
else
{
lblMessage.Text = "Sazeh saved";
LoadData();
}
}
else
{
lblMessage.Text = "Error saving Sazeh";
DataEntryMode = PageDataEntryMode.ErrorOccurred;
}
}
示例3: Page_PreInit
protected void Page_PreInit(object sender, EventArgs e)
{
if (Request.Url.Host.StartsWith("www") && !Request.Url.IsLoopback)
{
UriBuilder builder = new UriBuilder(Request.Url);
builder.Host = Request.Url.Host.Substring(Request.Url.Host.IndexOf("www.") + 4);
Response.Redirect(builder.ToString(), true);
}
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string formatPrice = ConfigurationManager.AppSettings[WebMobilConstant.FORMATPRICE];
//Se setean valores personales como telefono e email
email.HRef = String.Format("mailto:{0}",ConfigurationManager.AppSettings["email"]);
telefono.HRef = String.Format("tel:{0}", ConfigurationManager.AppSettings["telefono"]);
linkTel.HRef = String.Format("tel:{0}", ConfigurationManager.AppSettings["telefono"]);
ltrTelefono.Text = ConfigurationManager.AppSettings["telefono"];
//Se obtiene la casa y se imprime valores
int id=Convert.ToInt32(Request.QueryString["ID"]);
CasasResultById casa = Casas.ObtenerCasasById(id);
//Se setea la seccion de compatir
UriBuilder uri=new UriBuilder(Uri.UriSchemeHttp,Request.Url.Host,80,"Detalle.aspx","?ID="+id.ToString());
linkFacebook.HRef += String.Format("Se {0} {1}, mirala en el siguiente link {2}",casa.TipoTransaccion,casa.TipoInmueble,uri.ToString());
linkTwitter.HRef += String.Format("Se {0} {1}, mirala en el siguiente link {2}", casa.TipoTransaccion, casa.TipoInmueble, uri.ToString());
linkCorreo.HRef += String.Format("Se {0} {1}, mirala en el siguiente link {2}", casa.TipoTransaccion, casa.TipoInmueble, uri.ToString());
ltrVendedor.Text = ConfigurationManager.AppSettings["vendedor"];
ltrBaños.Text = casa.Baños.ToString();
ltrCalle.Text = casa.Calle;
ltrCiudad.Text = casa.Ciudad;
ltrCiudad2.Text = casa.Ciudad;
ltrCodigoPostal.Text = casa.CodigoPostal;
ltrCodigoPostal2.Text = casa.CodigoPostal;
ltrColonia.Text = casa.Colonia.ToUpper();
ltrColonia2.Text = casa.Colonia;
ltrConstruccion.Text = casa.Construccion.ToString();
ltrID.Text = casa.ID.ToString();
ltrNiveles.Text = casa.Niveles.ToString();
ltrNumero.Text = casa.Numero;
ltrPrecio.Text = casa.Precio.ToString(formatPrice);
ltrPrecio2.Text = casa.Precio.ToString(formatPrice);
ltrTerreno.Text = casa.Terreno.ToString();
ltrTipoInmueble.Text = casa.TipoInmueble;
ltrTipoInmueble2.Text = casa.TipoInmueble;
ltrTipoTransaccion.Text = casa.TipoTransaccion;
fotografia.Src = casa.Fotografia;
}
示例5: CurrentDirectory
public static string CurrentDirectory()
{
//Use codebase because location fails for unit tests.
var assembly = typeof(AssemblyLocation).Assembly;
var uri = new UriBuilder(string.IsNullOrEmpty(assembly.CodeBase) ? assembly.Location : assembly.CodeBase);
if (uri.ToString().Contains("#"))
{
throw new NotSupportedException("'#' character in path is not supported while building projects containing Fody.");
}
var path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
示例6: MainWindow
public MainWindow () : base (Gtk.WindowType.Toplevel)
{
Build ();
mesh = new Mesh ();
mesh.Generate ();
textview2.Buffer.Text += "Hashname: " + mesh.Hashname + "\n";
var builder = new UriBuilder (mesh.URI);
builder.Host = "127.0.0.1";
builder.Port = 8989;
textview2.Buffer.Text += builder.ToString () + "\n";
udp = new UDPTransport (new System.Net.IPEndPoint (System.Net.IPAddress.Any, 8989));
udp.Listen (mesh);
mesh.DebugLogEvent += new DebugLogHandler (OnDebugLog);
}
示例7: IssueIDTextBox_TextChanged
protected void IssueIDTextBox_TextChanged(object sender, EventArgs e)
{
int new_id = Int32.Parse(IssueIDTextBox.Text);
if (new_id > 0)
{
UriBuilder redirect = new UriBuilder(Page.Request.Url);
redirect.Query = "IssueID=" + new_id.ToString();
Page.Response.Redirect(redirect.ToString(), true);
}
}
示例8: ReportIDTextBox_TextChanged
protected void ReportIDTextBox_TextChanged(object sender, EventArgs e)
{
TextBox reportid_tb = (TextBox)LoginView1.FindControl("ReportIDTextBox");
int new_id = Int32.Parse(reportid_tb.Text);
if (new_id > 0)
{
UriBuilder redirect = new UriBuilder(Page.Request.Url);
redirect.Query = "ReportID=" + new_id.ToString();
Page.Response.Redirect(redirect.ToString(), true);
}
}
示例9: ToString_Invalid
public void ToString_Invalid()
{
var uriBuilder = new UriBuilder();
uriBuilder.Password = "password";
Assert.Throws<UriFormatException>(() => uriBuilder.ToString()); // Uri has a password but no username
}
示例10: ToString
public void ToString(UriBuilder uriBuilder, string expected)
{
Assert.Equal(expected, uriBuilder.ToString());
}
示例11: RedirectWithSortExpression
/// <summary>
/// Sets the the sort expression in the url and
/// redirects to the url
/// </summary>
/// <param name="sortExpression">The column name to sort on</param>
/// <remarks>
/// The sort direction is checked and inverted
/// if the sort expression is the same as the current sort expression in the query string
/// </remarks>
protected void RedirectWithSortExpression(string sortExpression)
{
RAD.AppFramework.QueryObjects.SortDirection SortDirectionCurrent = GetSortDirection();
if (sortExpression == GetSortExpression())
{
//
// The sort is on the same column so switch the sort direction
//
if (SortDirectionCurrent == RAD.AppFramework.QueryObjects.SortDirection.Ascending)
{
SortDirectionCurrent = RAD.AppFramework.QueryObjects.SortDirection.Descending;
}
else
{
SortDirectionCurrent = RAD.AppFramework.QueryObjects.SortDirection.Ascending;
}
}
else
{
//
// Sorting on a different column so change back to the default sort
//
SortDirectionCurrent = RAD.AppFramework.QueryObjects.SortDirection.Ascending;
}
UriBuilder UrlWithSort = new UriBuilder(Request.Url);
UrlWithSort.Query = ChangeQueryStringValue(UrlWithSort.Query, SortParameterName, sortExpression);
UrlWithSort.Query = ChangeQueryStringValue(UrlWithSort.Query, SortDirectionParameterName, SortDirectionCurrent.ToString());
Response.Redirect(UrlWithSort.ToString());
}
示例12: ProcessFirstQuery
private void ProcessFirstQuery(string query, int sortIndex)
{
UriBuilder queryBuilder = new UriBuilder("http", "www.freesound.org");
queryBuilder.Path = "/api/sounds/search";
string sortMode = "";
switch(sortIndex)
{
case 0:
sortMode = "duration_desc";
break;
case 1:
sortMode = "duration_asc";
break;
case 2:
sortMode = "created_desc";
break;
case 3:
sortMode = "created_asc";
break;
case 4:
sortMode = "downloads_desc";
break;
case 5:
sortMode = "downloads_asc";
break;
case 6:
sortMode = "rating_desc";
break;
case 7:
sortMode = "rating_asc";
break;
}
query = query.Replace(" ", "+");//replace spaces with AND operator (default)
queryBuilder.Query += "p=1" + "&q=" + query + "&s=" + sortMode + "&api_key=" + FreesoundHandler.Instance.ApiKey;
www_ = new WWW(queryBuilder.ToString());
}
示例13: createNewSubscriptionRedirectUrl
/// <summary>
/// This function return redirect url string for new subscription
/// </summary>
/// <param name="apiKey">apiKey</param>
/// <param name="secretKey">secretKey</param>
/// <param name="amount">amount</param>
/// <param name="category">category</param>
/// <param name="channel">channel</param>
/// <param name="description">description</param>
/// <param name="merchantTransactionId">apiKmerchantTransactionIdey</param>
/// <param name="merchantProductId">merchantProductId</param>
/// <param name="merchantRedirectURI">merchantRedirectURI</param>
/// <param name="merchantSubscriptionId">merchantSubscriptionId</param>
/// <param name="isPurchaseOnNoActiveSubscription">isPurchaseOnNoActiveSubscription</param>
/// <param name="subscriptionRecurringNumber">subscriptionRecurringNumber</param>
/// <param name="subscriptionRecurringPeriod">subscriptionRecurringPeriod</param>
/// <param name="subscriptionRecurringPeriodAmount">subscriptionRecurringPeriodAmount</param>
public string createNewSubscriptionRedirectUrl(
string apiKey,
string secretKey,
double amount,
int category,
string channel,
string description,
string merchantTransactionId,
string merchantProductId,
string merchantRedirectURI,
string merchantSubscriptionId,
bool isPurchaseOnNoActiveSubscription,
int subscriptionRecurringNumber,
string subscriptionRecurringPeriod,
int subscriptionRecurringPeriodAmount)
{
string payloadString = subNotary.getPyaloadString(category, amount,
channel, description, merchantTransactionId,
merchantProductId, merchantRedirectURI, merchantSubscriptionId,
isPurchaseOnNoActiveSubscription, subscriptionRecurringNumber,
subscriptionRecurringPeriod, subscriptionRecurringPeriodAmount);
subNotary.SubmitToNotary(payloadString, apiKey, secretKey);
if (String.IsNullOrEmpty(subNotary.signedPayload) || String.IsNullOrEmpty(subNotary.signedSignature))
{
throw new Exception("There's no signed payload or signed signature.");
}
else
{
var builder = new UriBuilder(endPoint + "/rest/3/Commerce/Payment/Subscriptions");
var query = HttpUtility.ParseQueryString(builder.Query);
query["clientid"] = apiKey;
query["SignedPaymentDetail"] = subNotary.signedPayload;
query["Signature"] = subNotary.signedSignature;
builder.Query = query.ToString();
return builder.ToString();
//return apiService.requestUri + "Transactions?clientid=" + apiKey + "&SignedPaymentDetail=" + subNotary.signedPayload + "&Signature=" + subNotary.signedSignature;
}
}
示例14: createNewTransactionRedirectUrl
/// <summary>
/// This function return redirect url string for creating new transaction
/// </summary>
/// <summary>
/// Create new transaction
/// </summary>
/// <param name="apiKey">apiKey</param>
/// <param name="secretKey">secretKey</param>
/// <param name="amount">amount</param>
/// <param name="category">category</param>
/// <param name="channel">channel</param>
/// <param name="description">description</param>
/// <param name="merchantTransactionId">apiKmerchantTransactionIdey</param>
/// <param name="merchantProductId">merchantProductId</param>
/// <param name="merchantRedirectURI">merchantRedirectURI</param>
public string createNewTransactionRedirectUrl(
string apiKey,
string secretKey,
string description,
double amount,
int category,
string channel,
string merchantRedirectURI,
string merchantProductId,
string merchantTransactionId
)
{
string payloadString = tranNotary.getPyaloadString(description, category, amount,
channel, merchantRedirectURI, merchantProductId, merchantTransactionId);
tranNotary.SubmitToNotary(payloadString, apiKey, secretKey);
if (String.IsNullOrEmpty(tranNotary.signedPayload) ||
String.IsNullOrEmpty(tranNotary.signedSignature))
{
throw new Exception("There's no signed payload or signed signature.");
}
else
{
var builder = new UriBuilder(endPoint + "/rest/3/Commerce/Payment/Transactions");
var query = HttpUtility.ParseQueryString(builder.Query);
query["clientid"] = apiKey;
query["SignedPaymentDetail"] = tranNotary.signedPayload;
query["Signature"] = tranNotary.signedSignature;
builder.Query = query.ToString();
return builder.ToString();
//return apiService.requestUri
// + "Transactions?clientid=" + apiKey
// + "&SignedPaymentDetail=" + tranNotary.signedPayload
// + "&Signature=" + tranNotary.signedSignature;
}
}
示例15: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Request.QueryString["logout"] != null && Request.QueryString["logout"] == "Y")
LogoutClicked();
string publicUrl = PublicUrl;
string backUrl = BackUrl;
//topPanelLinkPublic.HRef = publicUrl + "&isdesignmode=N";// + "&=";
//zg
topPanelLinkPublic.HRef = InjectQueryParameters(
publicUrl,
BXConfigurationUtility.Constants.BackUrlAdmin, backUrl,
BXConfigurationUtility.Constants.ShowModeParamName, BXConfigurationUtility.GetShowModeParamValue(BXShowMode.View)
);
topPanelLinkContent.HRef = InjectQueryParameters(
publicUrl,
BXConfigurationUtility.Constants.BackUrlAdmin, backUrl,
BXConfigurationUtility.Constants.ShowModeParamName, BXConfigurationUtility.GetShowModeParamValue(BXShowMode.Editor)
);
topPanelLinkDesign.HRef = InjectQueryParameters(
publicUrl,
BXConfigurationUtility.Constants.BackUrlAdmin, backUrl,
BXConfigurationUtility.Constants.ShowModeParamName, BXConfigurationUtility.GetShowModeParamValue(BXShowMode.Configurator)
);
topPanelLinkAdmin.HRef = ((Request.ApplicationPath.Length > 0 && !Request.ApplicationPath.Equals("/", StringComparison.InvariantCultureIgnoreCase)) ? Request.ApplicationPath : "") + "/bitrix/admin/Default.aspx";
BXPrincipal user = Context.User as BXPrincipal;
List<BXTopPanelButton> buttons = new List<BXTopPanelButton>();
if (user.Identity.IsAuthenticated)
{
if(user.IsCanOperate(BXRoleOperation.Operations.ProductSettingsView))
{
string p = VirtualPathUtility.ToAbsolute("~/bitrix/admin/Settings.aspx") + "?" + BXConfigurationUtility.Constants.BackUrl + "=" + HttpUtility.UrlEncode(BXSefUrlManager.CurrentUrl.PathAndQuery);
// try to get current module by scanning modules dir - TODO: implement a better method
string module = null;
string vp = Page.AppRelativeVirtualPath;
if (vp != null && vp.StartsWith("~/bitrix/admin/", StringComparison.OrdinalIgnoreCase))
{
string strip = vp.Substring("~/bitrix/admin/".Length);
string pp = MapPath("~/bitrix/modules/");
foreach (Bitrix.Modules.BXModule m in Bitrix.Modules.BXModuleManager.InstalledModules)
{
if (System.IO.File.Exists(pp + m.ModuleId + "\\install\\system\\admin\\" + strip))
{
module = m.GetType().FullName;
break;
}
}
}
if (module != null)
p = p + "&module_id=" + HttpUtility.UrlEncode(module);
// ---
buttons.Add(new BXTopPanelButton(GetMessage("Kernel.TopPanel.Settings"), GetMessage("Kernel.TopPanel.SettingsTitle"), p, "top_panel_settings"));
}
if (BXConfigurationUtility._SiteUpdateSystemAvailable && user.IsCanOperate(BXRoleOperation.Operations.UpdateSystem))
{
if (buttons.Count > 0)
buttons.Add(new BXTopPanelButton(true));
buttons.Add(new BXTopPanelButton(GetMessage("Kernel.TopPanel.UpdatesTitle"), BXPath.ToVirtualAbsolutePath("~/bitrix/admin/UpdateSystem.aspx"), "top_panel_update"));
}
}
BXLanguageCollection locales = BXLanguage.GetList(new BXFilter(new BXFilterItem(BXLanguage.Fields.Active, BXSqlFilterOperators.Equal, true)), null);
if (locales.Count > 0)
{
if (buttons.Count > 0)
buttons.Add(new BXTopPanelButton(true));
foreach (BXLanguage l in locales)
{
UriBuilder u = new UriBuilder(Request.Url);
StringBuilder q = new StringBuilder();
foreach (string key in Request.QueryString.AllKeys)
{
if (string.IsNullOrEmpty(key))
continue;
if (key.Equals("lang", StringComparison.InvariantCultureIgnoreCase))
continue;
if (q.Length != 0)
q.Append("&");
q.Append(key);
q.Append("=");
q.Append(HttpUtility.UrlEncode(Request.QueryString[key]));
}
if (q.Length != 0)
q.Append("&");
q.Append("lang=");
q.Append(HttpUtility.UrlEncode(l.Id));
u.Query = q.ToString();
BXTopPanelButton b = new BXTopPanelButton(l.Id, l.Name);
//.........这里部分代码省略.........