问题描述
我想在我的sql server上上传1gb视频文件,但得到了http:错误404.13。
请给一些建议来解决这个问题。
我尝试过:
WebConfig部分
< system.web>
<身份验证模式=无/>
<编译debug =truetarget Framework =4.5.2/>
< httpRuntime目标框架=4.5.2执行超时=999999最大请求长度=294857600/>
< /system.web>
控制器部分
公共ActionResult商店([Bind(Include =Mname,Mgenre,Mruntime,Mreleasedate,Mcreators) ,Mpath,Mdescription,Mstars,Mimage)] AdminUpload Aupload,IEnumerable< httppostedfilebase> upload)
{
string constrr = ConfigurationManager.ConnectionStrings [Mymoviestore]。ToString();
SqlConnection con = new SqlConnection(constrr);
if(upload.ElementAt( 0)!= null)
{
var file1 = upload.ElementAt(0);
if(file1!= null&& ; file1.ContentLength> 0)
{
string filename = System.IO.Path.GetFileName(file1.FileName);
file1.SaveAs(Server.MapPath(〜/ Movie /+ filename))
SqlCommand cmd = new SqlCommand(sp_MovieDB,con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
cmd.Parameters.AddWithValue(@ Mname,Aupload.Mname);
cmd.Parameters.AddWithValue(@ Mgenre,Aupload.Mgenre);
cmd.Parameters.AddWithValue(@ Mruntime,Aupload.Mruntime);
cmd.Parameters.AddWithValue(@ Mreleasedate,Aupload.Mreleasedate);
cmd.Parameters.AddWithValue(@ Mcreators,Aupload.Mcreators);
cmd.Parameters.AddWithValue(@ Mpath,〜/ Movie /+ file1.FileName);
cmd.Parameters.AddWithValue(@ Mdescription,Aupload.Mdescription);
cmd.Parameters.AddWithValue(@ Mstars,Aupload.Mstars);
cmd.Parameters.AddWithValue(@ Mimage,〜/ Coverimage /+ filename);
cmd.Parameters.Add(@ err,SqlDbType.VarChar,50);
cmd.Parameters [@ err]。Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
string result =(cmd.Parameters [@ err]。Value.ToString());
con.Close();
ViewBag.Message =结果;
ModelState.Clear();
}
Hi,
I am trying to upload 1gb video files on my sql server but got http:error 404.13.
Please give some suggestion to solve the issue.
What I have tried:
WebConfig Part
< system.web >
< authentication mode="None" />
< compilation debug="true" target Framework="4.5.2" />
< httpRuntime target Framework="4.5.2" execution Timeout="999999" max Request Length="294857600" />
< /system.web>
Controller part
public ActionResult Store([Bind(Include = "Mname,Mgenre,Mruntime,Mreleasedate,Mcreators,Mpath,Mdescription,Mstars,Mimage")]AdminUpload Aupload,IEnumerable<httppostedfilebase> upload)
{
string constrr = ConfigurationManager.ConnectionStrings["Mymoviestore"].ToString();
SqlConnection con = new SqlConnection(constrr);
if (upload.ElementAt(0) != null)
{
var file1 = upload.ElementAt(0);
if (file1 != null && file1.ContentLength > 0)
{
string filename = System.IO.Path.GetFileName(file1.FileName);
file1.SaveAs(Server.MapPath("~/Movie/" + filename))
SqlCommand cmd = new SqlCommand("sp_MovieDB", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
cmd.Parameters.AddWithValue("@Mname", Aupload.Mname);
cmd.Parameters.AddWithValue("@Mgenre", Aupload.Mgenre);
cmd.Parameters.AddWithValue("@Mruntime", Aupload.Mruntime);
cmd.Parameters.AddWithValue("@Mreleasedate", Aupload.Mreleasedate);
cmd.Parameters.AddWithValue("@Mcreators", Aupload.Mcreators);
cmd.Parameters.AddWithValue("@Mpath", "~/Movie/" + file1.FileName);
cmd.Parameters.AddWithValue("@Mdescription", Aupload.Mdescription);
cmd.Parameters.AddWithValue("@Mstars", Aupload.Mstars);
cmd.Parameters.AddWithValue("@Mimage", "~/Coverimage/" + filename);
cmd.Parameters.Add("@err", SqlDbType.VarChar, 50);
cmd.Parameters["@err"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
string result = (cmd.Parameters["@err"].Value.ToString());
con.Close();
ViewBag.Message = result;
ModelState.Clear();
}
这篇关于如何在ASP.NET MVC中上传1gb文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!