C# 如何获取Url的host以及是否是http
参考资料:https://sites.google.com/site/netcorenote/asp-net-core/get-scheme-url-host
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的host以及是否是http的更多相关文章
- js获取URL中的参数
js获取URL中的一些参数的意思 location对象 含有当前URL的信息. 属性 href 整个URL字符串. protocol 含有URL第一部分的字符串,如http: host 包含有URL中 ...
- js获取url信息
设置或获取对象指定的文件名或路径. alert(window.location.pathname) 设置或获取整个 URL 为字符串. alert(window.location.href); 设置或 ...
- js获取url的常用方法
//设置或获取对象指定的文件名或路径. console.log(window.location.pathname) //设置或获取整个 URL 为字符串. console.log(window.loc ...
- js获取url方法
//设置或获取对象指定的文件名或路径.alert(window.location.pathname); //设置或获取整个 URL 为字符串.alert(window.location.href); ...
- 一个用php实现的获取URL信息的类
获取URL信息的类 使用这个类,你能获得URL的如下信息: - Host - Path - Statuscode (eg. 404,200, ...) - HTTP Version - Ser ...
- js获取url传递参数
<head> <meta charset="UTF-8"> <title></title> <script type=&quo ...
- js获取url传递的参数
获取URL带参数的JAVASCRIPT客户端解决方案 一.正则分析法.(我较喜欢使用正则)function GetQueryString(name) {var reg = new RegExp(“(^ ...
- javascript获取url信息的常见方法
先以"http://www.cnblogs.com/wuxibolgs329/p/6188619.html#flag?test=12345"为例,然后获得它的各个组成部分. 1.获 ...
- JS获取url参数及url编码、解码
完整的URL由这几个部分构成:scheme://host:port/path?query#fragment ,各部分的取法如下: window.location.href:获取完整url的方法:,即s ...
随机推荐
- History of program
第一阶段:1950与1960年代 1.三个现代编程语言: (1)Fortran (1955),名称取自"FORmula TRANslator"(公式翻译器),由约翰·巴科斯等人所发 ...
- postgrel执行VACUUM报VACUUM cannot run inside a transaction block
在python脚本里执行: sql_gp1 = "VACUUM dwd_access_record_inout_temp" sql_gp2 = "delete from ...
- SEED实验——return-to-libc实验
实验概述 本实验的学习目标是让学生获得缓冲区溢出攻击的一种有趣变体——return-to-libc攻击实验的亲身体验.这种攻击可以绕过目前在主要linux操作系统中实现的现有保护方案.利用缓冲区溢出漏 ...
- create-react-app创建的项目中registerServiceWorker.js文件的作用
使用React官方的脚手架工具create-react-app创建的项目,目录中会存在registerServiceWorker.js这个文件,这个文件的作用是什么呢? 这个文件可以使用也可以不使用, ...
- C语言面试题分类->回调
本文主要讲解如果实现回调,特别是在封装接口的时候,回调显得特别重要,我们首先假设有两个程序员在写代码,A程序员写底层驱动接口,B程序员写上层应用程序,然而此时底层驱动接口A有一个数据d需要传输给B,此 ...
- [Swift]LeetCode165. 比较版本号 | Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 &l ...
- [Swift]LeetCode874. 模拟行走机器人 | Walking Robot Simulation
A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of th ...
- [Swift]LeetCode951. 翻转等价二叉树 | Flip Equivalent Binary Trees
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left a ...
- Identity Server 4 中文文档(v1.0.0) 目录
欢迎来到IdentityServer4 第一部分 简介 第1章 背景 第2章 术语 第3章 支持和规范 第4章 打包和构建 第5章 支持和咨询选项 第6章 演示服务器和测试 第7章 贡献 第二部分 快 ...
- Spring Boot druid监控页添加登录访问权限(用户名+密码)
需求 druid作为数据源的一名后起之秀,凭借其出色的性能,渐渐被大家使用.当然还有他的监控页面也有这非常大的作用.但是监控页面往往包含了很多隐私的数据信息,所以需要将其保密,所以可以为监控页面添加一 ...