我想写一个小助手方法,它返回网站的基本URL.这就是我想出的:
public static string GetSiteUrl()
{
string url = string.Empty;
HttpRequest request = HttpContext.Current.Request;
if (request.IsSecureConnection)
url = "https://";
else
url = "http://";
url += request["HTTP_HOST"] + "/";
return url;
}
Run Code Online (Sandbox Code Playgroud)
这有什么错误,你能想到吗?任何人都可以改进吗?
还有另一个用于进行名为NancyFx的HTTP调用的框架.我的问题是使用它有什么好处.我快速查看了文档:
https://github.com/NancyFx/Nancy/wiki/Documentation
看起来没有突出的功能,因此我想使用它.通过WebHttp使用它有什么好处?
PS:我一直在读一些不断重复的"超级快乐路径"的奇怪短语.除了这种"超级快乐的道路"之外还有什么东西吗?实现了哪些真正的功能
我正在使用ffmpeg进行音频转换.我正在使用此命令:
ffmpeg -i file.mp3 file.wav
Run Code Online (Sandbox Code Playgroud)
这很好用.但是我只希望我的输出文件包含最多1分钟的音频.我怎么能用ffmpeg做到这一点?
我想在RedirectToAction中传递对象.这是我的代码:
RouteValueDictionary dict = new RouteValueDictionary();
dict.Add("searchJob", searchJob);
return RedirectToAction("SearchJob", "SearchJob", dict);
Run Code Online (Sandbox Code Playgroud)
其中searchJob是SearchJob的实例.但我没有得到SearchJob动作方法的数据.相反,我得到searchJob = Entity.SearchJob的查询字符串.请帮我.我究竟做错了什么?
此代码是否会造成内存泄漏?
WebClient client = new WebClient();
client.DownloadDataCompleted += (sen, args) => {
};
client.DownloadData("http://foo.bar");
Run Code Online (Sandbox Code Playgroud)
因为没有办法真正取消订阅活动.我可以说我们绝不能使用lambda进行活动订阅吗?
我获得了一个http git存储库URL以及用户名和密码.我安装了git并尝试使用Tortoisegit克隆存储库但不知何故它无法正常工作.这些是截图:

我点击确定后,我被要求输入用户名和密码.我进入了那个然后我得到了这个截图:

我是git的新手,之前从未使用过git.我完全不知道为什么会这样.有人可以帮帮我吗?最后,我获得成功,这意味着服务器存储库本身是空的还是我错过了什么?
我不希望我的列表是固定类型.相反,我希望List的创建依赖于变量的类型.此代码不起作用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string something = "Apple";
Type type = something.GetType();
List<type> list = null;
Console.ReadKey();
}
}
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我需要做些什么改变才能让它正常工作?我希望创建list依赖于变量的类型something
我在IIS中托管了一个站点,但每当我浏览该站点时,我都会得到404.4.我怎么解决这个问题?我已经提到了几个帖子,他们都说这个问题是关于staticfile的,但它已经被映射了.我还能做什么?这是我的iis 7.0中处理程序映射的附加图片

有任何想法吗?
编辑:
我有这个网址重写器设置:
<rules>
<rule name="Imported Rule 1-1" enabled="true" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{SERVER_PORT}" pattern="80" />
</conditions>
<action type="Rewrite" url="https://abc.com/{R:1}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
当我禁用此规则时,http://请求被正确处理.但是当我启用它时,我收到此错误.
又一次更新:
如果我替换它:
<action type="Rewrite" url="https://abc.com/{R:1}" />
Run Code Online (Sandbox Code Playgroud)
同
<action type="Redirect" url="https://abc.com/{R:1}" />
Run Code Online (Sandbox Code Playgroud)
这一切都很顺利.
我正在使用一些第三方课程.我想得到我的控制器的路由值.不幸的是,它并没有把我正在执行的当前控制器交给我.我可以从HttpContext获取它吗?
该类看起来像:
public class ServiceStationVisibilityProvider
: ISiteMapNodeVisibilityProvider
{
public bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata)
{
node.Title = DateTime.Now.ToString(); //need to access routevalues and set title
return true;
}
Run Code Online (Sandbox Code Playgroud)
现在我可以手动检查Request.RawUrl并解析并做一些时髦的事情.但是,我不想写那种,并在应用程序增长后遇到麻烦.}
有一个基类有一个泛型类型的方法,我相信在我的派生中我将返回一个字符串.这是我的代码:
public abstract class Base
{
public virtual T GetSomething<T>()
{
return default(T);
}
}
public class Extended : Base
{
public override string GetSomething<string>()
{
return string.Empty;
//return base.GetSomething<T>();
}
}
Run Code Online (Sandbox Code Playgroud)
但是这段代码没有编译.任何人都可以发现错误吗?我确信在我的Extended类中我只想返回字符串.我该如何解决这个问题?
c# ×7
asp.net ×5
asp.net-mvc ×2
.net ×1
ffmpeg ×1
generics ×1
git ×1
httprequest ×1
iis ×1
iis-7 ×1
nancy ×1
reflection ×1
rest ×1
tortoisegit ×1
uri ×1
webhttp ×1