C# 获取Url 请求方式 域名 端口 路径
Example there's an given url: http://localhost:4800/account/login
获取整个url地址:
在页面(cstml)中
Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(Context.Request);
在 Controller 中
Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(Request);
获取请求的方式(scheme:http/https):http
In asp.net 4.6 -> Request.Url.Scheme
in .net core -> Context.Request.Scheme (cshtml) , in Controller -> Request.Scheme
获取域名(不带端口号)[Get the host]:
In asp.net 4.6 -> Request.Url.Host
in .net core -> Context.Request.Host.Host (cshtml) , in Controller -> Request.Host.Host
获取域名(带端口号)[Get the host]: localhost:4800
In asp.net 4.6 ->
in .net core -> Context.Request.Host.Value (cshtml) , in Controller -> Request.Host.Value
获取路径(Get the path): /account/login
In asp.net 4.6:
In .net core: @Context.Request.Path (cshtml)
获取端口号(Get port): 4800 (if a url contains port)
In asp.net 4.6: Request.Url.Port
In .net core: @Context.Request.Host.Port (cshtml) , in Controller -> Request.Host.Port
C# 获取Url 请求方式 域名 端口 路径的更多相关文章
- 【C++】获取URL中主机域名
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <windows.h& ...
- JS获取url请求参数
JS获取url请求参数,代码如下: // 获取url请求参数 function getQueryParams() { var query = location.search.substring(1) ...
- springboot获取URL请求参数的多种方式
1.直接把表单的参数写在Controller相应的方法的形参中,适用于get方式提交,不适用于post方式提交. /** * 1.直接把表单的参数写在Controller相应的方法的形参中 * @pa ...
- springboot(服务端接口)获取URL请求参数的几种方法
原文地址:http://www.cnblogs.com/xiaoxi/p/5695783.html 一.下面为7种服务端获取前端传过来的参数的方法 常用的方法为:@RequestParam和@Req ...
- springboot获取URL请求参数的几种方法
原文地址:http://www.cnblogs.com/xiaoxi/p/5695783.html 1.直接把表单的参数写在Controller相应的方法的形参中,适用于get方式提交,不适用于pos ...
- c#获取url请求的返回值(转)
有两种方式获取. 方法一: /// <summary> /// 获取url的返回值 /// </summary> /// <param name="url&qu ...
- c#获取url请求的返回值
/// <summary> /// 获取url的返回值 /// </summary> /// <param name="url">eg:http ...
- PHP 用正则获取URL的根域名
function GetUrlRoot($url){ preg_match('/[\w][\w-]*\.(?:com\.cn|com|cn|co|net|org|gov|cc|biz|info)(\/ ...
- JS 获取get请求方式的参数
//获取页面中的参数 name值参数名称(例如:http://localhost:8099/index.aspx?id=10,name则指的是id)function GetQueryString ...
随机推荐
- PAT L3-004 肿瘤诊断(三维广搜)
在诊断肿瘤疾病时,计算肿瘤体积是很重要的一环.给定病灶扫描切片中标注出的疑似肿瘤区域,请你计算肿瘤的体积. 输入格式: 输入第一行给出4个正整数:M.N.L.T,其中M和N是每张切片的尺寸(即每张切片 ...
- oracle 使用正则表达式获取字符串中包含的数字
select REGEXP_REPLACE('字符串中包含的数字123,提取后就是123', '[^0-9]', '') from dual;
- 215. Kth Largest Element in an Array(QuickSort)
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...
- ASP.NET MVC HtmlHelper 默认值
例如: @Html.HiddenFor(m=>m.IsMating,new { Value="True"}) 注意:value属性的首字母要用大写.
- PAT 1057 数零壹 (20)(代码+思路)
1057 数零壹(20 分) 给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一下 N 的二 ...
- geoserver的rest服务介绍,搭建java程序
在geoserver中使用 Restlet 来提供所有的rest服务,并且geoserver中所有的在/rest目录下的请求都被看作为一个restful server,下图就是rest服务的调用过程 ...
- 一篇文章Tornado快速入门
Tornado是一个PythonWeb框架.一个异步网络库.通过使用非阻塞网络I/O,Tornado能够处理数以千计的连接,这意味着对于实时Web服务来说,Tornado是一个理想的Web框架. 作为 ...
- KindEditor解决上传视频不能在手机端显示的问题
KindEditor自带的上传视频生成的HTML代码为<embed>,在手机端并不支持.于是可以自己在控件里增加生成video标签相关代码. 参考https://www.jianshu.c ...
- 【Unity】2.2 Unity编辑器中的常用菜单项
分类:Unity.C#.VS2015 创建日期:2016-03-26 Unity 5.3.4编辑器共提供了7个主菜单项,这一节主要学习其中的常用项. 一.File 1.基本功能 New Scene:新 ...
- java多线程同步(转)
原文地址:http://developer.51cto.com/art/201509/490965.htm 一.场景 因为当我们有多个线程要同时访问一个变量或对象时,如果这些线程中既有读又有写操作时, ...