我在远程托管我的网站上有以下错误。我第一次部署它,代码就像我的本地机器上的魅力一样。这似乎是一个权限问题,我不需要担心权限问题,因为我正在上传到应用程序目录中的文件夹中。我不需要为该仪式授予特殊许可?所以我试图联系我的托管服务提供商,他们说没有任何关系。我通常可以在网络托管帐户中设置权限,以便我可以授予应用程序权限,或者如何解决此问题?我需要模仿用户吗?我不应该。该文件夹存在于网站上,并且在网站上还有其他歌曲。访问它们没有问题。希望有人能指出我发生了什么事。我刚刚购买了远程主机,我不明白它们是如何工作的。远程托管文件上传错误vb.net
非常感谢。在 '/' 应用
我上传的代码
If fuSong.HasFile = True Then
Dim conString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim con As New SqlConnection(conString)
Dim location As String = Path.Combine(Server.MapPath("~/Uploads"), fuSong.FileName)
Dim username As String = Page.User.Identity.Name
Dim Insertcommand As New SqlCommand()
Dim prsongname As New SqlParameter("@songname", SqlDbType.NVarChar)
prsongname.DbType = DbType.[String]
prsongname.Value = name
Insertcommand.Parameters.Add(prsongname)
Dim prusername As New SqlParameter("@username", SqlDbType.NVarChar)
prusername.DbType = DbType.[String]
prusername.Value = username
Insertcommand.Parameters.Add(prusername)
Insertcommand.CommandText = "INSERT INTO Songs(Song_Name, UserName) VALUES (@songname, @username)"
Insertcommand.Connection = con
con.Open()
Insertcommand.ExecuteNonQuery()
fuSong.SaveAs(location) ''''''''' I guess error is here
End If
服务器错误。
访问路径'D:\ Hosting \ 9078263 \ html \ Uploads \ Sleep Away.mp3'被拒绝。
描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关该错误的更多信息以及源代码的位置。
异常详细信息:System.UnauthorizedAccessException:访问路径'D:\ Hosting \ 9078263 \ html \ Uploads \ Sleep Away.mp3'被拒绝。
ASP.NET未被授权访问请求的资源。考虑将资源的访问权限授予ASP.NET请求标识。 ASP.NET具有基本进程标识(通常位于IIS 5上的{MACHINE} \ ASPNET或IIS 6和IIS 7上的网络服务以及IIS 7.5上配置的应用程序池标识),如果应用程序未模拟,则使用该标识。如果应用程序正在通过模拟,身份将是匿名用户(通常为IUSR_MACHINENAME)或经过身份验证的请求用户。
要授予对文件的ASP.NET访问权,请右键单击资源管理器中的文件,选择“属性”并选择安全选项卡。点击“添加”添加适当的用户或组。突出显示ASP.NET帐户,然后选中所需访问权限的复选框。
源错误:
在当前web请求的执行过程中生成未处理的异常。关于异常的来源和位置的信息可以使用下面的异常堆栈跟踪来标识。
堆栈跟踪:
[UnauthorizedAccessException:对路径 'd:\主机\ 9078263 \ HTML \上传\睡眠Away.mp3' 被拒绝。] System.IO .__ Error.WinIOError(的Int32的errorCode ,String maybeFullPath)+9717806 System.IO.FileStream.Init(String path,FileMode mode,FileAccess access,Int32 rights,Boolean useRights,FileShare share,Int32 bufferSize,FileOptions选项,SECURITY_ATTRIBUTES secAttrs,String msgPath,Boolean bFromProxy,Boolean useLongPath )+1142 System.IO.FileStream..ctor(String path,FileMode mode,FileAccess access,FileShare share,Int32 bufferSize,FileOptions options,String msgPath,Boolean bFromProxy)+78 Sys tem.IO.FileStream..ctor(String path,FileMode mode)+71 System.Web.HttpPostedFile.SaveAs(String filename)+99 profile。btnUpload_Click(对象发件人,EventArgs的)1231
[例外:数据错误:未添加记录] profile.btnUpload_Click(对象发件人,EventArgs的)1374 System.Web.UI.WebControls.Button.OnClick (EventArgs e)+118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)+112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint ,布尔includeStagesAfterAsyncPoint)+5563
不要忘记标记为其他用户的答案。 :) – ianbailey 2012-03-21 13:41:52