无法从IIS服务器将大于4KB的BLOB映像插入或更新到Oracle数据库,但可以从我的本地计算机上运行
我的控制器:无法从IIS服务器将大于4KB的BLOB映像插入或更新到Oracle数据库,但可以从我的本地计算机上运行,iis,server,byte,blob,Iis,Server,Byte,Blob,我的控制器: [HttpPost] [ValidateAntiForgeryToken] public ActionResult EditUserDetails(AuthorizedUser user, HttpPostedFileBase file) { try { var allowedExtensions = new[] { ".img", ".png", ".gif",".jpg&qu
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult EditUserDetails(AuthorizedUser user, HttpPostedFileBase file)
{
try
{
var allowedExtensions = new[] { ".img", ".png", ".gif",".jpg", ".tiff", ".bmp",".jpeg" };
user.Username = user.Username.Replace("-", @"\");
AuthorizedUser userDetails;
if (file != null && file.ContentLength > 0)
{// extract only the fieldname
var fileName = Path.GetFileName(file.FileName);
// store the file inside ~/Content/reweb/images/signature folder
//var path = Path.Combine(Server.MapPath("~/Content/reweb/images/signature"), fileName);
//file.SaveAs(path);
var checkextension = Path.GetExtension(file.FileName).ToLower();
TempData["notice"] = "";
if (!allowedExtensions.Contains(checkextension))
{
TempData["notice"] = "Please select a image file (with extension of img, png, gif,jpg, tiff, bmp,jpeg)!";
return View(user);
}
if (file.ContentLength > 1000000)
{
TempData["notice"] = "the file size can't be excceded 1000kb!";
return View(user);
}
user.Signature = new byte[file.ContentLength];
file.InputStream.Seek(0, SeekOrigin.Begin);
file.InputStream.Read(user.Signature, 0, System.Convert.ToInt32(file.ContentLength));
TempData["notice"] = System.Convert.ToInt32(file.ContentLength);
file.InputStream.Close();
}
else
{
userDetails = starkUserRoleManager.GetUserDetails(user.Username);
user.Signature = userDetails.Signature;
}
if (ModelState.IsValid)
{
starkUserRoleManager.EditUser(user.Username, user.Email, user.Fullname, user.Signature);
}
return RedirectToAction("Index");
}
catch (Exception ex)
{
throw ex;
}
}
我的代码保存到数据库:
public void EditUser(string username, string email, string fullname, byte[] signature)
{
if(username == null || username == "")
{
throw new Exception("The username cannot be null or empty.");
}
using(OracleConnection conn = new OracleConnection(connectionString))
using (OracleCommand cmd = new OracleCommand())
using (OracleParameter p_username = new OracleParameter("p_username", OracleDbType.Varchar2, ParameterDirection.Input),
p_email = new OracleParameter("p_email", OracleDbType.Varchar2, ParameterDirection.Input),
p_fullname = new OracleParameter("p_fullname", OracleDbType.Varchar2, ParameterDirection.Input),
p_signature = new OracleParameter("p_signature", OracleDbType.Blob, ParameterDirection.Input))
{
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SC_RE_WEB_API.app_users_update";
cmd.BindByName = true;
p_username.Value = username.ToUpper();
cmd.Parameters.Add(p_username);
p_email.Value = email == null ? (object)DBNull.Value : email;
cmd.Parameters.Add(p_email);
p_fullname.Value = fullname== null ? (object)DBNull.Value : fullname;
cmd.Parameters.Add(p_fullname);
p_signature.Value = signature == null ? (object)DBNull.Value : signature;
cmd.Parameters.Add(p_signature);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
throw ex;
}
}
}
保存后的错误消息:
ORA-64219:遇到无效的LOB定位器
描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源
异常详细信息:Oracle.ManagedDataAccess.Client.OracleException:ORA-64219:遇到无效的LOB定位器
源错误:
在执行当前web请求期间生成了未经处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来识别
堆栈跟踪:
[OracleException(0xfadb):ORA-64219:遇到无效的LOB定位器]
C:\Users\jxliu\Source\Repos\RealEstateWeb\RealEstateWeb\Controllers\AuthorizationController.EditUserDetails(AuthorizedUser,HttpPostedFileBase文件)中的RealEstateWeb.Controllers.AuthorizationController.EditUserDetails(AuthorizedUser,HttpPostedFileBase文件):167
lambda_方法(闭包、控制器基、对象[])+191
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,ActionDescriptor ActionDescriptor,IDictionary2参数)+35 System.Web.Mvc.Async.c.b_uu9_0(IAsyncResult asyncResult,ActionInvokeState InnerEstate)+39 System.Web.Mvc.Async.WrappedAsyncResult
2.CallEndDelegate(IAsyncResult asyncResult asyncResult) +77
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)+42
System.Web.Mvc.Async.c_uuuudisplayClass11_0.b_uuu0()+80
System.Web.Mvc.Async.c\uuuu DisplayClass11\u2.b\uuu2()+387
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)+42
System.Web.Mvc.Async.c\uuuu DisplayClass3\u6.b\uu4()+50
System.Web.Mvc.Async.c__显示类3_1.b_1(IAsyncResult asyncResult)+188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)+38
System.Web.Mvc.c.b__152_1(IAsyncResult asyncResult,ExecuteCorerate innerState)+26
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult)+73 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)+52 System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult)+39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)+38
System.Web.Mvc.c.b_20_1(IAsyncResult asyncResult,ProcessRequestState innerState)+40
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)+73
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+602
System.Web.HttpApplication.executesteppl(IExecutionStep步骤)+195
System.Web.HttpApplication.ExecuteStep(IExecutionStep,Boolean&completedSynchronously)+128正如堆栈跟踪所述,LOB定位器有一个异常。您可以参考此线程了解oracle-64219异常。