我正在尝试将视频文件从ASP.NET MVC提供给iPhone客户端.视频格式正确,如果我在一个可公开访问的网络目录中,它可以正常工作.
我所读到的核心问题是,iPhone要求您拥有一个可随时使用的简历下载环境,该环境允许您通过HTTP标头过滤字节范围.我认为这是为了让用户可以跳过视频.
使用MVC提供文件时,这些标头不存在.我试图模仿它,但没有运气.我们这里有IIS6,我根本无法做很多标题操作.ASP.NET将我抱怨说:" 此操作需要IIS综合管道模式. "
升级不是一种选择,我不允许将文件移动到公共Web共享.我觉得受到环境的限制,但我仍在寻找解决方案.
以下是我正在尝试做的一些示例代码...
public ActionResult Mobile(string guid = "x")
{
guid = Path.GetFileNameWithoutExtension(guid);
apMedia media = DB.apMedia_GetMediaByFilename(guid);
string mediaPath = Path.Combine(Transcode.Swap_MobileDirectory, guid + ".m4v");
if (!Directory.Exists(Transcode.Swap_MobileDirectory)) //Make sure it's there...
Directory.CreateDirectory(Transcode.Swap_MobileDirectory);
if(System.IO.File.Exists(mediaPath))
return base.File(mediaPath, "video/x-m4v");
return Redirect("~/Error/404");
}
Run Code Online (Sandbox Code Playgroud)
我知道我需要做这样的事情,但是我无法在.NET MVC中做到这一点.http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx
以下是一个有效的HTTP响应标头示例:
Date Mon, 08 Nov 2010 17:02:38 GMT
Server Apache
Last-Modified Mon, 08 Nov 2010 17:02:13 GMT
Etag "14e78b2-295eff-4cd82d15"
Accept-Ranges bytes
Content-Length 2711295
Content-Range bytes 0-2711294/2711295
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Content-Type text/plain
Run Code Online (Sandbox Code Playgroud)
这是一个没有的例子(这是来自.NET) …
我正在尝试以编程方式更改外部可执行文件的图标.我用谷歌搜索,并使用C++找到有关此问题的大量信息.基本上,我需要使用BeginUpdateResource,UpdateResource和EndUpdateResource.问题是 - 我不知道在C#中传递给UpdateResource的内容.
这是我到目前为止的代码:
class IconChanger
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr BeginUpdateResource(string pFileName,
[MarshalAs(UnmanagedType.Bool)]bool bDeleteExistingResources);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool UpdateResource(IntPtr hUpdate, string lpType, string lpName, ushort wLanguage,
IntPtr lpData, uint cbData);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool EndUpdateResource(IntPtr hUpdate, bool fDiscard);
public enum ICResult
{
Success,
FailBegin,
FailUpdate,
FailEnd
}
public ICResult ChangeIcon(string exeFilePath, byte[] iconData)
{
// Load executable
IntPtr handleExe = BeginUpdateResource(exeFilePath, false);
if (handleExe == null)
return ICResult.FailBegin;
// Get …Run Code Online (Sandbox Code Playgroud) 我试图在函数内更改函数之外的变量.因为如果函数检查的日期超过一定数量,我需要它来更改代码开头的日期年份.
$var = "01-01-10";
function checkdate(){
if("Condition"){
$var = "01-01-11";
}
}
Run Code Online (Sandbox Code Playgroud) 我有几个类扩展内置日期时间.*
有没有什么好的理由不重载+(MyTime.__radd___)所以MyDate + MyTime返回一个MyDateTime?
有没有办法用javascript/jquery/crazy-css-hack来检测用户的浏览器是否支持渲染功能<input type="file" />文件上传元素?例如,iOS上的safari浏览器不会呈现该元素,而是希望向用户显示不支持该功能的消息.我知道我可以检查用户代理并检查它是否是iphone/ipad /等,但我不知道其他浏览器做了什么或不支持它,或者将来是否会支持它.
在我的Java应用程序中,如何检测Internet连接速度有多快?例如,我在家里使用AT&T Fast DSL,我想知道是否有办法可以编写一个执行以下操作的方法:
int getInternetConnectionSpeed()
{
...
}
Run Code Online (Sandbox Code Playgroud)
这将返回一个以kbps为单位的数字,例如2800kbps [2.8 M]
编辑:我问的原因是,在我的应用程序中,我可以打开多个Internet流,具体取决于用户的Internet连接速度,我希望它自动确定打开多少流而不会阻塞应用程序.
有没有办法为泛型的参数T提供默认类型,如:
class Something<T = string>
{
}
Run Code Online (Sandbox Code Playgroud)
我知道没有太多强有力的理由,但我想暗示代码客户端应该优先使用哪种类型.
另一件事,我可以将泛型类型限制为我刚看到你不能,但我仍然想知道为什么.有人有线索吗?ValueType?
谢谢!
我从表中选择了一行:
select * from LCTs WHERE LCTGUID = 'B642B9E6-779A-4FD0-8514-294EAF87A9A6'
(1 row(s) affected)
(3 row(s) affected)
Run Code Online (Sandbox Code Playgroud)
如何获得受单个选择影响的4行(特别是因为它只返回一行)?
奖金信息:
更奇怪的是,如果我更新那一行:
update LCTs SET IsDirty = 1 WHERE LCTGUID = 'B642B9E6-779A-4FD0-8514-294EAF87A9A6'
(1 row(s) affected)
(5 row(s) affected)
Run Code Online (Sandbox Code Playgroud)
在SQL Server 2000中,如何在表中没有触发器的情况下更新一行影响6行?
我为'messages'创建了一个脚手架,new_message_path和edit_message_path(在link_to中使用)都已设置好,但现在我已经创建了app/views/messages/sent.html.erb,我想要沿着行<%= link_to'Send',sent_message_path%>,但我无法弄清楚如何做到这一点.我明白了
undefined local variable or method `sent_message_path' for #<ActionView::Base:0x103117c50>
Run Code Online (Sandbox Code Playgroud) 我有一些计件工作由不同的自定义(源代码不可用)框架完成,这些框架可以传回Map实例.不幸的是,这些框架在返回的Map实例中并不一致,这些实例已用Collections.unmodifiableMap包装.为了确保在我的代码中更高程度的不变性(为了更容易的多线程使用),我在这些框架返回的任何内容上统一调用了Collections.unmodifiableMap.
Map<String, Record> immutableMap = framework.getRecordsByName();
//does this created a nested set of unmodifiableMap wrapper instances?
this.immutableField = Collections.unmodifiableMap(immutableMap);
.
.
.
Map<String, Record> maybeImmutableMap = framework.getRecordsByName();
//is there some means to get instanceof to work?
if (!(maybeImmutableMap instanceof Collections.UnmodifiableMap))
{
this.immutableField = Collections.unmodifiableMap(maybeImmutableMap);
}
Run Code Online (Sandbox Code Playgroud)
我意识到在这部分设计中我可能会遇到性能问题.在某些情况下,我正在调用Collections.unmodifiableMap传递一个实例,该实例已经由同一个调用的框架包装.而且我的重新包装可能会在整个实例中引起额外的方法调用.
似乎使用"instanceof Collections.UnmodifiableMap"不起作用.如果我当前引用的Map实例需要被包装,我找不到任何检测方法(不包括在这种情况下不是选项的反射 - 方式太慢).
问题:
c# ×2
java ×2
.net ×1
asp.net-mvc ×1
collections ×1
connection ×1
function ×1
generics ×1
global ×1
html ×1
icons ×1
instanceof ×1
iphone ×1
javascript ×1
map ×1
path ×1
performance ×1
php ×1
python ×1
records ×1
resources ×1
ruby ×1
select ×1
sql-server ×1
unmodifiable ×1
variables ×1