上传图片问题的BUG
开发工具:vs2005
语言:c#
技术:asp.net ado.net ajax.net
但发现一个超级郁闷的问题是:我用vs2005调试出的页面上传成功(在本机)但用IIS浏览出来的页面上传图片失败(也是在本机).
不知是什么意思啊?忘高人解惑.

解决方案 »

  1.   

    ??上传路径如果错了的话在VS调试的时候就会出错的啊,为什么在VS调试的时候是正确的,在IIS却是错误的?两个都是在本机运行的
      

  2.   

    我遇到类似问题,
    这个可能因为访问权限的缘故:
    在发布之前,你发送时,是采用本机默认的账户信息,但通过IIS则采用WEB默认账户,这个账户没有权限。
    所以在上传之前要先模拟登陆
    代码如下:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Security.Principal;
    using System.Runtime.InteropServices;/// <summary>
    /// Summary description for WindowsAuthentication
    /// </summary>
    public class WindowsAuthentication
    {    [DllImport("advapi32.dll", SetLastError = true)]
        private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
                   int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        private extern static bool CloseHandle(IntPtr handle);    public WindowsAuthentication()
        {
            //
            // TODO: Add constructor logic here
            //
        }    public static void CreateIdentity()
        {
            // The Windows NT user token.
            IntPtr tokenHandle = new IntPtr(0);
            const int LOGON32_PROVIDER_DEFAULT = 0;
            const int LOGON32_LOGON_NETWORK_CLEARTEXT = 2;
            tokenHandle = IntPtr.Zero;
           //账户信息,写在配置文件中
            String[] tempAccount = ConfigurationManager.AppSettings["AspNetaccount"].ToString().Split(new char[] { ';' });
            bool returnValue = LogonUser(tempAccount[1], tempAccount[0], tempAccount[2],
                 LOGON32_LOGON_NETWORK_CLEARTEXT, LOGON32_PROVIDER_DEFAULT,
                 ref tokenHandle);
            if (false == returnValue)
            {
                int ret = Marshal.GetLastWin32Error();
                throw new Exception("LogonUser failed with error code: " + ret);
            }
            WindowsIdentity id = new WindowsIdentity(tokenHandle);
            CloseHandle(tokenHandle);
            id.Impersonate();
        }
    }
      

  3.   

    在配置文件中记载一个本域内,有相应权限的账户信息
    如:
     <appSettings>
        <add key="PathOfMarketingAutoMailList" value="\\server\Archive\Testautomails\"/>
        <add key="AspNetaccount" value="cadpro.com.cn;woodlee;0"/>
     //分别是: 域名 账户 密码
      </appSettings>
      

  4.   

    我的操作是在登录后再进行的,是用admin帐户登录的
      

  5.   

    <add key="PathOfMarketingAutoMailList" value="\\server\Archive\Testautomails\"/>
    这帮注释下啊value="\\server\Archive\Testautomails\"