c# - MVC4 - Ajax.ActionLink() GET returning 500 internal server error -
When I click on a I said that 3 partially implemented with functionality, which works fine. On which I am working, it should initially show a list of uploaded images - if the user did not upload any image, When I press the link, then I'm looking into Chrome: here gET and POST I and I 'has solved the problem I was returning the Ajax.ActionLink , I get 500 internal server errors . I have a profile page which is composed of several partial forms. Each partial has asked the server to allow Ajax to edit the user information related to that particular partial.
Ajax.ActionLink will be displayed first, which will be clicked on Provides a user to partially upload images.
ActionResults :
// / / receive / tenants / TenantUploadReference [HttpGet] public ActionResult TenantUploadReference () {try {var currentTenant = tenantRepository.GetLoggedInTenant (); If (currentantant.refesphoto == empty) {currentTenant.ReferencePhotos = currentTenant.ReferencePhotos ?? New list & lt; Reference photo & gt; (); } Return a partial view ("_ tenantUploadReferencePartial", currentTenet.rereferols.toList ()); } Hold (exception e) {ModelState.AddModelError ("", e); See Return (); }} // // POST: / tenants / TenantUploadReference [HttpPost] public ActionResult TenantUploadReference (HttpPostedFileBase file, tenant) {if {try {if (file.ContentLength & gt; 10240) {ModelState.AddModelError ((file = null! ) "File", "the file size should not exceed 10 KB"); See Return (); } Var supportedTypes = new [] {"jpg", "jpeg", "png", "jpg", "jpeg", "png"}; Var fileExt = System.IO.Path.GetExtension (file.FileName) .Substring (1); If (Supported text. Canton (File AEXT)) {ModelState. Adod Eltar ("Photo", "Invalid type. Only the following types are supported (JPG, JPEG, PNG)."); See Return (); } (Var db = new LetLordContext ()) using {var reference = db.Image.Create & lt; Reference photo & gt; (); // Convert HttpPostedFileBase byte array to memoryStream target = new MemoryStream (); File.InputStream.CopyTo (target); Byte [] Photo = Target. ToArray (); Reference. File = photo; Reference. Format = fileext; Reference. Data-uploaded = date time.NEW.DAT; Reference. Description = ""; Context.Name = ""; Db.Image.Add (reference); Db.SaveChanges (); Back partial view ("_ tenantReference PhotoShot", file); }} And {return view (); }} Hold (exception e) {ModelState.AddModelError ("", e); See Return (); }}
to step through the debugger with a break point ActionResult hit
return PartialView and no exceptions Is thrown away.
_TenantUploadReferencePartial I
@using (Ajax.BeginForm ( "TenantUploadReference", "tenants", FormMethod.Post, using new AjaxOptions {InsertionMode = InsertionMode.Replace, HttpMethod = "post", UpdateTargetId = "tenant reference pictures"}))
_TenantReferencePhotosPartial (where
ActionLink I throw a 500 error) I use this
@if (Model.ReferencePhotos == faucet) {& lt; H3 & gt; You have not uploaded any references! Upload @ Ajaks.akshnlink ( "Now?", "Tennant Uploderefrens" new Ajax option {Apdettabagaidi = "tenant-reference photos," Prvishtimod = Nivishtimod. Replays, Acteepimaideepi = "GET", Lodingilementaid = "Ajax-loader" }) And lieutenant; / H3 & gt; It may also be useful to know that other part-time work on the page does the required work, so I do not think it is an issue with missing scripts. I am at a loss as to why this is happening - a solution would be greatly appreciated.
currentTennet. Reference photo ..ToList () which threw a
Argumental exposure . Now I'm just returning to
current center , and GET is working as expected.
Comments
Post a Comment