草庐IT

URL重写

全部标签

c# - Request.Url.GetLeftPart(UriPartial.Authority) 在 https 站点上返回 http

我们使用Request.Url.GetLeftPart(UriPartial.Authority)获取站点的域部分。这满足了我们对http的要求。我们最近将站点更改为https(大约3天前),但这仍然返回http://..url全部改为https显示在浏览器地址栏中。知道为什么会这样吗? 最佳答案 以下示例工作正常并返回带有“https”的字符串:varuri=newUri("https://www.google.com/?q=102njgn24gk24ng2k");varauthority=uri.GetLeftPart(UriP

c# - 从任意 URL 手动实例化 Controller 实例?

我的技能让我失望了,我知道我已经看过相关代码,但找不到它。获取任意URL、通过asp.netmvc路由系统运行它并在另一端产生对Controller实例的引用的最快方法是什么?例如,代码执行在某个任意Controller方法中。我想做这样的事情:...stringmyURL="http://mysite/mycontroller/myaction/myparameters";RouteDatafakeRouteData=newRouteData(Route???,IRouteHandler???)RequestContextctxt=newRequestContext(this.Con

c# - SQL 语句的某些部分嵌套太深。重写查询或将其分解为更小的查询

我的Controller中有调用以下方法的操作:publicIQueryablegetcontactinfo(long[]id){varorganizationsiteids=fromaccountsitemappinginentities.AccountSiteMappingswhereid.Any(accountid=>accountsitemapping.ACCOUNTID==accountid)selectaccountsitemapping.SITEID;varusersdepts=fromuserdeptinentities.UserDepartmentsjoindeptd

c# - asp.net 中 ./, ../, ../../, ~/on file path(URL) 之间的区别

我有一个脚本文件。看到路径是~/Script。但是,如果我输入../../而不是~/,该过程也同样有效。我的网站URL如:https://sample.com/Scripts/angular.js如果我在Scripts之前输入../../,那么它会自动更改以前的URL(https://sample.com/Scripts/angular.js).Whatistheurlprocess?Andhowcanitsautomaticallychanged?andpleasetellabouttheDifferentbetween./,../,../../,~/,/Scripts,Script

c# - 在 WinRT 的默认 Web 浏览器中打开 URL

这个问题说明了一切。基本上,我只想知道WinRT中的替代方案:Process.Start("http://www.google.com/"); 最佳答案 在WinRT中,您可以使用Windows.System.Launcher.LaunchUriAsync启动与指定URI关联的默认应用。对于Web链接,将使用默认浏览器。MSDN:Launcher.LaunchUriAsync(Uri)|launchUriAsync(Uri)method 关于c#-在WinRT的默认Web浏览器中打开UR

c# - 让用户输入格式正确的 URL 的最佳方式?

我正在使用MVVM创建一个对话框,它会提示用户输入KML文件的http://URL。当URL格式正确时需要启用“确定”按钮,当URL格式不正确时需要禁用它。现在按钮绑定(bind)到ICommand,CanExecute()的逻辑如下所示:return!string.IsNullOrEmpty(CustomUrl);每次击键都会引发命令的CanExecuteChanged事件,到目前为止它运行良好。现在我想做一些实际的验证。我知道的唯一方法如下:try{varuri=newUri(CustomUrl);}catch(UriFormatException){returnfalse;}re

c# - 将 HasValue 重写为 ??运营商

重写以下代码是否安全:boolb=foo.bar.HasValue?foo.bar.Value:false;到boolb=foo.bar.Value??false;bar是可空类型bool? 最佳答案 最简单的解决方法是boolb=foo.bar.GetValueOrDefault();这实际上也比.Value便宜,因为它省略了有值检查。它将默认为default(T),这里确实是false(它只是返回底层T字段的值,没有任何检查完全没有)。如果您需要与default(T)不同的默认值,那么:varvalue=yourNullable

c# - 用于 URL 验证的正则表达式

我已经编写了正则表达式来验证URL,它可能是这样的google.comwww.google.comhttp://www.google.comhttps://www.google.com我用过RegexurlRx=newRegex(@"^(http|ftp|https|www)://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?$",RegexOptions.IgnoreCase);它适用于http和https。它不适用于google./com和www.google.com。请帮我解决这

c# - Selenium 错误 : No response from server for url http://localhost:7055

我正在使用Selenium、C#、NUnit编写测试,有时我会遇到以下错误:-OpenQA.Selenium.WebDriverException:Noresponsefromserverforurlhttр://lоcalhost:7055/hub/session/8dd13f5c-7ca6-4aa6-babc-f0ff6d940f0a/element这是堆栈跟踪:OpenQA.Selenium.WebDriverException:Noresponsefromserverforurlhttр://localhost:7055/hub/session/8dd13f5c-7ca6-4a

c# - ASP.NET MVC URL 生成性能

ASP.NETMVC的一个小基准测试。查看页面代码:publicstringBechmark(Funcurl){vars=newStopwatch();varn=1000;s.Reset();s.Start();for(inti=0;i";}查看代码:Url.Action("Login","Account"))%>Url.Action("Login","Account",new{username="bla",password="bla2",returnurl="blabla32",rememberme=false}))%>Html.BuildUrlFromExpression(a=>a