• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UriBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UriBuilder的典型用法代码示例。如果您正苦于以下问题:C# UriBuilder类的具体用法?C# UriBuilder怎么用?C# UriBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UriBuilder类属于命名空间,在下文中一共展示了UriBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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;
            }
    }
开发者ID:MKsattari,项目名称:palizAmlak,代码行数:35,代码来源:Sazeh.ascx.cs


示例2: MsiHackExtension

    public MsiHackExtension()
    {
        /* Figure out where we are. */
        string strCodeBase = Assembly.GetExecutingAssembly().CodeBase;
        //Console.WriteLine("MsiHackExtension: strCodeBase={0}", strCodeBase);

        UriBuilder uri = new UriBuilder(strCodeBase);
        string strPath = Uri.UnescapeDataString(uri.Path);
        //Console.WriteLine("MsiHackExtension: strPath={0}", strPath);

        string strDir = Path.GetDirectoryName(strPath);
        //Console.WriteLine("MsiHackExtension: strDir={0}", strDir);

        string strHackDll = strDir + "\\MsiHack.dll";
        //Console.WriteLine("strHackDll={0}", strHackDll);

        try
        {
            IntPtr hHackDll = NativeMethods.LoadLibrary(strHackDll);
            Console.WriteLine("MsiHackExtension: Loaded {0} at {1}!", strHackDll, hHackDll.ToString("X"));
        }
        catch (Exception Xcpt)
        {
            Console.WriteLine("MsiHackExtension: Exception loading {0}: {1}", strHackDll, Xcpt);
        }
    }
开发者ID:svn2github,项目名称:virtualbox,代码行数:26,代码来源:MsiHackExtension.cs


示例3: UriBuilder_Ctor_NullParameter_ThrowsArgumentException

 public void UriBuilder_Ctor_NullParameter_ThrowsArgumentException()
 {
     Assert.Throws<ArgumentNullException>(() =>
    {
        UriBuilder builder = new UriBuilder((Uri)null);
    });
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:UriBuilderParameterTest.cs


示例4: TryReadQueryAsSucceeds

        public void TryReadQueryAsSucceeds()
        {
            object value;
            UriBuilder address = new UriBuilder("http://some.host");

            address.Query = "a=2";
            Assert.True(address.Uri.TryReadQueryAs(typeof(SimpleObject1), out value), "Expected 'true' reading valid data");
            SimpleObject1 so1 = (SimpleObject1)value;
            Assert.NotNull(so1);
            Assert.Equal(2, so1.a);

            address.Query = "b=true";
            Assert.True(address.Uri.TryReadQueryAs(typeof(SimpleObject2), out value), "Expected 'true' reading valid data");
            SimpleObject2 so2 = (SimpleObject2)value;
            Assert.NotNull(so2);
            Assert.True(so2.b, "Value should have been true");

            address.Query = "c=hello";
            Assert.True(address.Uri.TryReadQueryAs(typeof(SimpleObject3), out value), "Expected 'true' reading valid data");
            SimpleObject3 so3 = (SimpleObject3)value;
            Assert.NotNull(so3);
            Assert.Equal("hello", so3.c);

            address.Query = "c=";
            Assert.True(address.Uri.TryReadQueryAs(typeof(SimpleObject3), out value), "Expected 'true' reading valid data");
            so3 = (SimpleObject3)value;
            Assert.NotNull(so3);
            Assert.Equal("", so3.c);

            address.Query = "c=null";
            Assert.True(address.Uri.TryReadQueryAs(typeof(SimpleObject3), out value), "Expected 'true' reading valid data");
            so3 = (SimpleObject3)value;
            Assert.NotNull(so3);
            Assert.Equal("null", so3.c);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:35,代码来源:UriExtensionsTests.cs


示例5: OnActionExecuting

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var httpsPort = Convert.ToInt32(ConfigurationManager.AppSettings["httpsPort"]);
            var httpPort = Convert.ToInt32(ConfigurationManager.AppSettings["httpPort"]);
            var request = filterContext.HttpContext.Request;
            var response = filterContext.HttpContext.Response;

            if (httpsPort > 0 && RequireSecure)
            {
                string url = null;
                if (httpsPort > 0)
                {
                    url = "https://" + request.Url.Host + request.RawUrl;

                    if (httpsPort != 443)
                    {
                        var builder = new UriBuilder(url) { Port = httpsPort };
                        url = builder.Uri.ToString();
                    }
                }
                if (httpsPort != request.Url.Port)
                {
                    filterContext.Result = new RedirectResult(url);
                }
            }
            // se for uma conexao segura e não está requerendo um SSL, retira o ssl e volta para http.
            else if (filterContext.HttpContext.Request.IsSecureConnection && !RequireSecure)
            {
                filterContext.Result = new RedirectResult(filterContext.HttpContext.Request.Url.ToString().Replace("https:", "http:").Replace(httpsPort.ToString(), httpPort.ToString()));
                filterContext.Result.ExecuteResult(filterContext);
            }
            base.OnActionExecuting(filterContext);
    }
开发者ID:rodrigoporcionato,项目名称:CodeStaff,代码行数:33,代码来源:RequireHttpsAttribute.cs


示例6: page_command

    protected void page_command(object sender, CommandEventArgs e)
    {
        int page = 1;

        switch (e.CommandName) {

            case "first": page = 1; break;
            case "prev": page = Convert.ToInt32(Request.QueryString["page"]) - 1; break;
            case "page": page = Convert.ToInt32(e.CommandArgument); break;
            case "next": page = Convert.ToInt32(Request.QueryString["page"]) + 1; break;
            case "last":
                int count = global::User.FindUsers(Request.QueryString["name"]).Count;
                page = Convert.ToInt32(Math.Ceiling((double)(count - 1) / (double)RESULTS));
                break;
        }

        UriBuilder u = new UriBuilder(Request.Url);
        NameValueCollection nv = new NameValueCollection(Request.QueryString);

        nv["page"] = page.ToString();

        StringBuilder sb = new StringBuilder();
        foreach (string k in nv.Keys)
            sb.AppendFormat("&{0}={1}", k, nv[k]);

        u.Query = sb.ToString();

        Response.Redirect(u.Uri.ToString());
    }
开发者ID:BrechtBonte,项目名称:JobFinder,代码行数:29,代码来源:joboffers.aspx.cs


示例7: GetDomain

        public static void GetDomain(string fromUrl, out string domain, out string subDomain)
        {
            domain = "";
            subDomain = "";
            try
            {
                if (fromUrl.IndexOf("����Ƭ") > -1)
                {
                    subDomain = fromUrl;
                    domain = "��Ƭ";
                    return;
                }

                UriBuilder builder = new UriBuilder(fromUrl);
                fromUrl = builder.ToString();

                Uri u = new Uri(fromUrl);

                if (u.IsWellFormedOriginalString())
                {
                    if (u.IsFile)
                    {
                        subDomain = domain = "�ͻ��˱����ļ�·��";

                    }
                    else
                    {
                        string Authority = u.Authority;
                        string[] ss = u.Authority.Split('.');
                        if (ss.Length == 2)
                        {
                            Authority = "www." + Authority;
                        }
                        int index = Authority.IndexOf('.', 0);
                        domain = Authority.Substring(index + 1, Authority.Length - index - 1).Replace("comhttp","com");
                        subDomain = Authority.Replace("comhttp", "com");
                        if (ss.Length < 2)
                        {
                            domain = "����·��";
                            subDomain = "����·��";
                        }
                    }
                }
                else
                {
                    if (u.IsFile)
                    {
                        subDomain = domain = "�ͻ��˱����ļ�·��";
                    }
                    else
                    {
                        subDomain = domain = "����·��";
                    }
                }
            }
            catch
            {
                subDomain = domain = "����·��";
            }
        }
开发者ID:yangningyuan,项目名称:webs_ShuSW,代码行数:60,代码来源:UrlOper.cs


示例8: GetCodeBaseDirectory

 /// <summary>
 /// Gets the assembly's location, i.e. containing directory.
 /// </summary>
 /// <param name="assembly">The assembly whose location to return.</param>
 /// <returns><see cref="System.String" /> representing the assembly location.</returns>
 public static string GetCodeBaseDirectory(this Assembly assembly)
 {
     string codeBase = Assembly.GetExecutingAssembly().CodeBase;
     UriBuilder uri = new UriBuilder(codeBase);
     string path = Uri.UnescapeDataString(uri.Path);
     return Path.GetDirectoryName(path);
 }
开发者ID:rlvandaveer,项目名称:heliar-composition,代码行数:12,代码来源:Assembly.cs


示例9: Start

        /// <summary>
        /// Start the Uri with the base uri
        /// </summary>
        /// <param name="etsyContext">the etsy context</param>
        /// <returns>the Uri builder</returns>
        public static UriBuilder Start(EtsyContext etsyContext)
        {
            UriBuilder instance = new UriBuilder(etsyContext);
            instance.Append(etsyContext.BaseUrl);

            return instance;
        }
开发者ID:annwitbrock,项目名称:Netsy,代码行数:12,代码来源:UriBuilder.cs


示例10: Main

    static void Main(string[] args)
    {
        Console.WriteLine("---------------------------------------------------------");
        Console.WriteLine("Preparing nServer...");

        // prepare primary endpoint URL
        UriBuilder uriBuilder = new UriBuilder("http",
            Server.Configurations.Server.Host,
            Server.Configurations.Server.Port);
        Console.WriteLine(String.Format("Setting up to listen for commands on {0}...", uriBuilder.Uri.ToString()));

        // register controllers
        Console.WriteLine("Registering all controllers...");
        Server.Controllers.ControllerManager.RegisterAllControllers();

        // start it up
        nServer server = new nServer(uriBuilder.Uri);
        nServer.CurrentInstance = server;
        server.IncomingRequest += RequestHandler.HandleIncomingRequest;
        server.Start();

        // ping to test it's alive and ready
        Console.WriteLine("Pinging to confirm success...");
        uriBuilder.Path = "server/ping";
        WebRequest request = WebRequest.Create(uriBuilder.Uri);
        WebResponse response = request.GetResponse();
        response.Close();

        Console.WriteLine("nServer ready to accept requests...");
        Console.WriteLine("---------------------------------------------------------");
    }
开发者ID:chrisbaglieri,项目名称:nServer,代码行数:31,代码来源:Program.cs


示例11: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!YZAuthHelper.IsAuthenticated)
        {

            FormsAuthentication.RedirectToLoginPage();
            return;
        }
        UriBuilder uriBuilder = new UriBuilder(this.Request.Url);

        string host = this.Request.Headers["host"];
        if (!String.IsNullOrEmpty(host))
        {
            int index = host.LastIndexOf(':');
            if (index != -1)
            {
                string port = host.Substring(index + 1);
                uriBuilder.Port = Int32.Parse(port);
            }
        }
        Uri uri = uriBuilder.Uri;
        string url = uri.GetLeftPart(UriPartial.Authority);

        string virtualPath = HttpRuntime.AppDomainAppVirtualPath;
        if (virtualPath == "/")
            virtualPath = String.Empty;

        url = url + virtualPath + "/";
        string jscode = String.Format("var rootUrl='{0}';\n var userAccount = '{1}';", url, YZAuthHelper.LoginUserAccount);
        HtmlGenericControl js = new HtmlGenericControl("script");
        js.Attributes["type"] = "text/javascript";
        js.InnerHtml = jscode;
           // this.Page.Header.Controls.AddAt(0, js);
    }
开发者ID:linxueyang,项目名称:F7,代码行数:34,代码来源:index.aspx.cs


示例12: Uri

        public Uri(UriBuilder builder)
        {
            scheme = builder.getScheme();
            authority = builder.getAuthority();
            path = builder.getPath();
            query = builder.getQuery();
            fragment = builder.getFragment();
            queryParameters = new Dictionary<string,List<string>>(builder.getQueryParameters());

            StringBuilder _out = new StringBuilder();

            if (!String.IsNullOrEmpty(scheme))
            {
                _out.Append(scheme).Append(':');
            }
            if (!String.IsNullOrEmpty(authority)) 
            {
                _out.Append("//").Append(authority);
            }
            if (!String.IsNullOrEmpty(path)) 
            {
                _out.Append(path);
            }
            if (!String.IsNullOrEmpty(query)) 
            {
                _out.Append('?').Append(query);
            }
            if (!String.IsNullOrEmpty(fragment)) 
            {
                _out.Append('#').Append(fragment);
            }
            text = _out.ToString();
        }
开发者ID:s7loves,项目名称:pesta,代码行数:33,代码来源:Uri.cs


示例13: FixIpv6Hostname

 // Originally: TcpChannelListener.FixIpv6Hostname
 private static void FixIpv6Hostname(UriBuilder uriBuilder, Uri originalUri)
 {
     if (originalUri.HostNameType == UriHostNameType.IPv6)
     {
         string ipv6Host = originalUri.DnsSafeHost;
         uriBuilder.Host = string.Concat("[", ipv6Host, "]");
     }
 }
开发者ID:dmetzgar,项目名称:wcf,代码行数:9,代码来源:TransportSecurityHelpers.cs


示例14: AssemblyLocation

 static AssemblyLocation()
 {
     var assembly = typeof(AssemblyLocation).Assembly;
     var uri = new UriBuilder(assembly.CodeBase);
     var currentAssemblyPath = Uri.UnescapeDataString(uri.Path);
     CurrentDirectory = Path.GetDirectoryName(currentAssemblyPath);
     ExeFileName = Path.GetFileNameWithoutExtension(currentAssemblyPath);
 }
开发者ID:nulltoken,项目名称:PlatformInstaller,代码行数:8,代码来源:AssemblyLocation.cs


示例15: CurrentDirectory

    public static string CurrentDirectory()
    {
        var assembly = typeof(AssemblyLocation).Assembly;
        var uri = new UriBuilder(assembly.CodeBase);
        var path = Uri.UnescapeDataString(uri.Path);

        return Path.GetDirectoryName(path);
    }
开发者ID:tenninebt,项目名称:Stamp,代码行数:8,代码来源:AssemblyLocation.cs


示例16: FullLocalPath

 public static string FullLocalPath(this Assembly assembly)
 {
     var codeBase = assembly.CodeBase;
     var uri = new UriBuilder(codeBase);
     var root = Uri.UnescapeDataString(uri.Path);
     root = root.Replace("/", "\\");
     return root;
 }
开发者ID:tobio,项目名称:OctoPack,代码行数:8,代码来源:AssemblyExtensions.cs


示例17: 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);
     }
 }
开发者ID:Hookem22,项目名称:Mayfly-Web,代码行数:9,代码来源:Default.aspx.cs


示例18: IdentityEndpoint20_NormalizeUri

	protected void IdentityEndpoint20_NormalizeUri(object sender, IdentityEndpointNormalizationEventArgs e) {
		// This sample Provider has a custom policy for normalizing URIs, which is that the whole
		// path of the URI be lowercase except for the first letter of the username.
		UriBuilder normalized = new UriBuilder(e.UserSuppliedIdentifier);
		string username = Request.QueryString["username"].TrimEnd('/').ToLowerInvariant();
		username = username.Substring(0, 1).ToUpperInvariant() + username.Substring(1);
		normalized.Path = "/user/" + username;
		normalized.Scheme = "http"; // for a real Provider, this should be HTTPS if supported.
		e.NormalizedIdentifier = normalized.Uri;
	}
开发者ID:Belxjander,项目名称:Asuna,代码行数:10,代码来源:user.aspx.cs


示例19: UriBuilder_ChangePort_Refreshed

 public void UriBuilder_ChangePort_Refreshed()
 {
     UriBuilder builder = new UriBuilder(s_starterUri);
     Assert.Equal<int>(s_starterUri.Port, builder.Port);
     Assert.Equal<int>(s_starterUri.Port, builder.Uri.Port);
     int newValue = 1010;
     builder.Port = newValue;
     Assert.Equal<int>(newValue, builder.Port);
     Assert.Equal<int>(newValue, builder.Uri.Port);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:10,代码来源:UriBuilderRefreshTest.cs


示例20: UriBuilder_ChangePath_Refreshed

 public void UriBuilder_ChangePath_Refreshed()
 {
     UriBuilder builder = new UriBuilder(s_starterUri);
     Assert.Equal<String>(s_starterUri.AbsolutePath, builder.Path);
     Assert.Equal<String>(s_starterUri.AbsolutePath, builder.Uri.AbsolutePath);
     String newValue = "/newvalue";
     builder.Path = newValue;
     Assert.Equal<String>(newValue, builder.Path);
     Assert.Equal<String>(newValue, builder.Uri.AbsolutePath);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:10,代码来源:UriBuilderRefreshTest.cs



注:本文中的UriBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UriComponents类代码示例发布时间:2022-05-24
下一篇:
C# Uri类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap