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 ...
随机推荐
- 带最小值操作的栈 · Min Stack
[抄题]: 实现一个带有取最小值min方法的栈,min方法将返回当前栈中的最小值. 你实现的栈将支持push,pop 和 min 操作,所有操作要求都在O(1)时间内完成. [思维问题]: [一句话思 ...
- Swift4 - 动态计算UITableView中tableHeaderView的高度 - 获取子控件高度和宽度
核心 : /// 获取 子控件高度 func sizeHeaderToFit(view:UIView) { view.setNeedsLayout() view.layoutIfNeeded() le ...
- 8-组成n的1的个数
/* ones时间限制:1000 ms | 内存限制:65535 KB难度:3 描述 Given a ...
- WPF之数据触发器 改变控件背景色或闪烁
需求,很多矩形表示桶,其中:空桶=红色,满桶=绿色,使用中=红绿闪烁. <Window x:Class="FlickerDemo.MainWindow" xmlns=&quo ...
- Java中弹出对话框中的几种方式
1.显示一个错误对话框,该对话框显示的 message 为 'alert': JOptionPane.showMessageDialog(null, "alert", " ...
- instanceof用法及本质:
import static java.lang.System.*; public class InstanceofTest{ public static void main(String[] args ...
- Web前端工程师常去的15个技术网站
1.CSDN 网址:https://www.csdn.net/ 简介: CSDN (Chinese Software Developer Network) 创立于1999年,是中国最大的IT社区和服务 ...
- 数据帮助类DBhelper的定义
数据库帮助类的使用DBhelperusing System;using System.Collections.Generic;using System.Text;using System.Data;u ...
- 2018.07.01洛谷P2617 Dynamic Rankings(带修主席树)
P2617 Dynamic Rankings 题目描述 给定一个含有n个数的序列a[1],a[2],a[3]--a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i ...
- UVa 12003 Array Transformer (分块)
题意:给定一个序列,然后有 m 个修改,问你最后的序列是什么,修改是这样的 l r v p 先算出从 l 到 r 这个区间内的 小于 v 的个数k,然后把第 p 个的值改成 k * u / (r - ...