﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-高山来客-最新评论</title><link>http://www.cnblogs.com/bashan/CommentsRSS.aspx</link><description /><language>zh-cn</language><pubDate>Fri, 29 Jul 2011 01:45:21 GMT</pubDate><lastBuildDate>Fri, 29 Jul 2011 01:45:21 GMT</lastBuildDate><generator>cnblogs</generator><item><title>Re:Asp.NET大文件上传组件开发总结(四)---封送数据给Asp.NET页面</title><link>http://www.cnblogs.com/bashan/archive/2010/12/23/1200572.html#1995696</link><dc:creator>牛腩</dc:creator><author>牛腩</author><pubDate>Thu, 23 Dec 2010 10:06:11 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/12/23/1200572.html#1995696</guid><description><![CDATA[大概意思理解，不过代码不会写，坐等源码下载。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">牛腩</a> 2010-12-23 18:06 <a href="http://www.cnblogs.com/bashan/archive/2010/12/23/1200572.html#1995696#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Asp.NET大文件上传组件开发总结_NET2.0源码下载。</title><link>http://www.cnblogs.com/bashan/archive/2010/12/01/1206097.html#1973720</link><dc:creator>jackie0609</dc:creator><author>jackie0609</author><pubDate>Tue, 30 Nov 2010 17:47:30 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/12/01/1206097.html#1973720</guid><description><![CDATA[int index = Array.IndexOf(this.m_FileConId, fileControlId.ToLower());  怎么一直提示这句值不能为空!<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">jackie0609</a> 2010-12-01 01:47 <a href="http://www.cnblogs.com/bashan/archive/2010/12/01/1206097.html#1973720#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:可以在没有安装Office的情况，使用.net代码操作Excel文件的代码</title><link>http://www.cnblogs.com/bashan/archive/2010/10/04/1192678.html#1928614</link><dc:creator>漂零</dc:creator><author>漂零</author><pubDate>Sun, 03 Oct 2010 17:00:43 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/10/04/1192678.html#1928614</guid><description><![CDATA[mengxj@yeah.net
也来晚了，谢谢了哈<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">漂零</a> 2010-10-04 01:00 <a href="http://www.cnblogs.com/bashan/archive/2010/10/04/1192678.html#1928614#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Asp.NET大文件上传组件开发总结_NET2.0源码下载。</title><link>http://www.cnblogs.com/bashan/archive/2010/08/30/1206097.html#1904560</link><dc:creator>Subroyal</dc:creator><author>Subroyal</author><pubDate>Mon, 30 Aug 2010 04:17:05 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/08/30/1206097.html#1904560</guid><description><![CDATA[博主你好，
    十分佩服您的这个解决方案。
    不过在使用您的.Net2.0源码中有一些问题，请博主查看一下。
     问题如下：使用的.Net2.0源码，在.Net4.0工程中引用的，有稍许修改，封装为ascx控件。
     上传中出错，通过跟踪，发现博主源码中引用控件的后台页代码中存在错误，源码如下：
protected void Button1_Click(object sender, EventArgs e)
        {
            UploadContext context = UploadContextFactory.GetUploadContext();
            if ((context != null) &amp;&amp; (context.Status == uploadStatus.Complete))
            {
                context.SaveFile(file1.ClientID, Request.MapPath(&quot;/myupload/&quot;));
            }
        }
这里出错的原因是使用了file1.ClientID,在.Net4.0中应该使用file1.Name.不知是不是与.Net2.0的差异所致。具体跟踪细节如下》
》在UploadContext.cs中的SaveFile（）函数中，第一行：
》int index = Array.IndexOf(this.m_FileConId, fileControlId.ToLower
》());
》对比this.m_FileConId的值和fileControldId的值可以发现，出现了引用错误
》根据名称，博主的原意应该是使用客户端控件的ID。然而在DataReader.cs--
》GetFileInfo()函数中，从buffer内提取的Content_Disposition中的
》lfileInfo.FileControl获取的是客户端控件的name，而不是ID。其值为“ctl00$MainContetn$uploadFile$file1”
》客户端的源代码如下：&lt;input name=&quot;ctl00$MainContetn$uploadFile$file1&quot; 
type=&quot;file&quot; id=&quot;ctl00_MainContent_uploadFile_File1&quot; /&gt;
从这里和lfileInfo.FileControl的值可以看出，在服务器端从buffer中提取的FileControl是客户端空间的Name，而不是ID。
所以m_FileConId的值实际上是客户端控件的Name，所以在int index = Array.IndexOf(this.m_FileConId, fileControlId.ToLower());中就必然出现错误。

解决方法，就是在page后台cs页中的file1.ClinetId换成file1.Name.

如果原方案能够编译成功，是因为上传控件&lt;input&gt;的id和name恰巧都命名为相同的“file1”了，并且在后台没有使用分级命名（因为源码中的控件在根页）。后台分级命名规则：id使用“_”串联，Name使用&quot;$&quot;串联。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">Subroyal</a> 2010-08-30 12:17 <a href="http://www.cnblogs.com/bashan/archive/2010/08/30/1206097.html#1904560#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:可以在没有安装Office的情况，使用.net代码操作Excel文件的代码</title><link>http://www.cnblogs.com/bashan/archive/2010/05/06/1192678.html#1817397</link><dc:creator>云中深海</dc:creator><author>云中深海</author><pubDate>Thu, 06 May 2010 01:33:35 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/05/06/1192678.html#1817397</guid><description><![CDATA[lifuyun023@163.com
是否来晚了？麻烦传给我一下。谢谢！ <br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">云中深海</a> 2010-05-06 09:33 <a href="http://www.cnblogs.com/bashan/archive/2010/05/06/1192678.html#1817397#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Asp.NET大文件上传开发总结(一)</title><link>http://www.cnblogs.com/bashan/archive/2010/05/02/1196054.html#1815284</link><dc:creator>别爱上哥，哥只是个传说！</dc:creator><author>别爱上哥，哥只是个传说！</author><pubDate>Sun, 02 May 2010 15:16:08 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/05/02/1196054.html#1815284</guid><description><![CDATA[[quote]Charrote：真不知你在写什么![/quote]
是因为你水平太菜了!根不知道的东西太多了<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">别爱上哥，哥只是个传说！</a> 2010-05-02 23:16 <a href="http://www.cnblogs.com/bashan/archive/2010/05/02/1196054.html#1815284#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Asp.NET大文件上传开发总结(一)</title><link>http://www.cnblogs.com/bashan/archive/2010/05/02/1196054.html#1815283</link><dc:creator>别爱上哥，哥只是个传说！</dc:creator><author>别爱上哥，哥只是个传说！</author><pubDate>Sun, 02 May 2010 15:15:49 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/05/02/1196054.html#1815283</guid><description><![CDATA[留爪!<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">别爱上哥，哥只是个传说！</a> 2010-05-02 23:15 <a href="http://www.cnblogs.com/bashan/archive/2010/05/02/1196054.html#1815283#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Asp.NET大文件上传组件开发总结(六)---大文件上传组件使用说明</title><link>http://www.cnblogs.com/bashan/archive/2010/03/16/1206095.html#1780073</link><dc:creator>舞千愁</dc:creator><author>舞千愁</author><pubDate>Tue, 16 Mar 2010 01:37:51 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/03/16/1206095.html#1780073</guid><description><![CDATA[上传着，显示无法显示该页，如果调 式的话，可以成功！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">舞千愁</a> 2010-03-16 09:37 <a href="http://www.cnblogs.com/bashan/archive/2010/03/16/1206095.html#1780073#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Asp.NET大文件上传组件开发总结(六)---大文件上传组件使用说明</title><link>http://www.cnblogs.com/bashan/archive/2010/03/12/1206095.html#1778116</link><dc:creator>New.min</dc:creator><author>New.min</author><pubDate>Fri, 12 Mar 2010 02:15:01 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/03/12/1206095.html#1778116</guid><description><![CDATA[楼主是四川的，，，，？？？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">New.min</a> 2010-03-12 10:15 <a href="http://www.cnblogs.com/bashan/archive/2010/03/12/1206095.html#1778116#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:可以在没有安装Office的情况，使用.net代码操作Excel文件的代码</title><link>http://www.cnblogs.com/bashan/archive/2010/02/23/1192678.html#1767159</link><dc:creator>双霜之君</dc:creator><author>双霜之君</author><pubDate>Tue, 23 Feb 2010 03:36:40 GMT</pubDate><guid>http://www.cnblogs.com/bashan/archive/2010/02/23/1192678.html#1767159</guid><description><![CDATA[tdskee@126.com
不知能否发一份呢？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bashan/" target="_blank">双霜之君</a> 2010-02-23 11:36 <a href="http://www.cnblogs.com/bashan/archive/2010/02/23/1192678.html#1767159#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>
