1

Topic: How the controler without I twist?

Greetings.
More truly, I need to fulfill action on the server, but not to return I twist. I twist  to be the same.
does not approach, it is a question of loading of a client file on the server:

<div class = "col-md-6">
@using (Html. BeginForm ("UploadNew", "Attachment", FormMethod. Post;
new {enctype = "multipart/form-data", id = "uploadNewDialog"}))
{
<input type = "hidden" name = "hf1" id = "hf1"/>
<label for = "file" >@TextResources.Strings.UploadAttachement:</label>
<input type = "file" name = "file" id = "file" style = "width: 100 %;"/>
<input type = "submit" onclick = "javascript: $ (' #hf1 ').val (jsCurrentFolder);" value = "Upload" class = "btn btn-info btn-block"/>
}
</div>

Thanks

2

Re: How the controler without I twist?

NickRenziglov;
Did not understand .
Is only post get ajax.
All.
The term the controler, it only for  the programmer.

3

Re: How the controler without I twist?

NickRenziglov;
It is possible here so

[HttpPost, ValidateAntiForgeryToken, Authorize]
public ActionResult AddAlbumPhoto ([Bind (Include = "UrlData, PreUploadedPhotoUrl, AlbumId")] AddAlbumPhotoCommand command)
{
var personId = User. Identity. GetPersonId ();
command. PersonId = personId;
var res = _commandDispatcher. CanDispatch (command);
if (! res. Any ())
{
_commandDispatcher. Dispatch (command);
Response. StatusCode = 200;
return Json (new {returnedPhotoId = command. ReturnedPhotoId, returnedPhotoUrl = command. ReturnedPhotoUrl, returnedOriginalPhotoUrl = command. ReturnedOriginalPhotoUrl}, JsonRequestBehavior. AllowGet);
}
else
{
Response. StatusCode = 400;
return Json (ValidationHelper. ShowResultAsHtmlList (res), JsonRequestBehavior. AllowGet);
}
}

Here front

$.ajax ({
type: "POST";
url: "/Manage/addalbumphoto";
data: data;
processData: false;
contentType: false;
beforeSend: showLoadingIndicator;
success: function () {
fetchAlbumPhotos (albumId;
function (data) {
$("#photo__container").html (data);
hideLoadingIndicator ();
$("#photo__add__dialog").modal ("hide");
});
};
error: function (xhr) {
showDispathErrors (xhr);
}
});

4

Re: How the controler without I twist?

big-duke;
He says, what AJAX does not approach (why?).
Then it in the code shows that wants  the form, to transfer a file, BUT not  page.

5

Re: How the controler without I twist?

The innocent person behind a board;
Well then the code of the controler suffices it.

6

Re: How the controler without I twist?

big-duke;
Here this piece:
data: data;
processData: false;
contentType: false;
Obviously, data it is defined so:

var data = new FormData ($ (this) [0]);

Where this is a form. So?
Nevertheless, controler function argument always comes null. Why?
What is AddAlbumPhotoCommand in your example?

7

Re: How the controler without I twist?

NickRenziglov;
. The problem Seems dared very simply.
The normal call of the controler works. But to return I twist it is not necessary. More truly, it is necessary, but here so:
return Content ("");
The page thus becomes empty. It is bad, I  from it and the beginnings. But it is necessary to tell to the browser
No Content. The server successfully processed the request and is not returning any content
It is reached by transmission of the appropriate code:
Response. StatusCode = 204;
return Content ("");
Both the controler fulfilled also page on a place.
To notify or update page, it is possible to implement in it corresponding StartupScript, but it already other history.
I love ASP.NET MVC.

8

Re: How the controler without I twist?

NickRenziglov;
Was specific in my case Data it is defined here so

var urldata = $ ("#imgCrop").cropper ("getCroppedCanvas").toDataURL ("image/jpeg");
var data = new FormData ();
data.append ("urldata", urldata);
data.append ("albumid", albumId);
data.append ("preuploadedphotourl", $ ("#imgCrop").attr ("src").replace ("/service/imageProxy? src =", ""));
data.append ("__ RequestVerificationToken", tokenValue);

But you can through F12 can check up on what at you specifies this.
AddAlbumPhotoCommand it is part CQRS, namely Command.

public class AddAlbumPhotoCommand: ICommand
{
public string PreUploadedPhotoUrl {get; set;}
public string UrlData {get; set;}
public int AlbumId {get; set;}
public int PersonId {get; set;}
...
}
public class AddAlbumPhotoCommandHandler: ICommandHandler <AddAlbumPhotoCommand>
{
public IEnumerable <ValidationResult> Validate (AddAlbumPhotoCommand command)
{
}
public void Execute (AddAlbumPhotoCommand command)
{
}
}

9

Re: How the controler without I twist?

NickRenziglov wrote:

NickRenziglov;
return Content ("");

Can so?

return new EmptyResult ();

10

Re: How the controler without I twist?

big-duke;
Not in essence. It is possible even to return the sound I twist type
return RedirectToAction ("Index");
But the code 204 solves all. The page remains old.

11

Re: How the controler without I twist?

NickRenziglov;
Can to you Partial View then  on page?

12

Re: How the controler without I twist?

big-duke;
> Can to you Partial View then  on page
Tried. All the same all page  the empty.
The decision with the code quite suits 204 me. It is unique that it is impossible to implement the error report or to update page.
As the page did not return (well, the code 204) any  a script on it, of course, not .
But it is technical trifles which dare in mass of methods.
Thanks.

13

Re: How the controler without I twist?

NickRenziglov;
If not a secret, why ajax under a ban?

14

Re: How the controler without I twist?

big-duke wrote:

NickRenziglov;
If not a secret, why ajax under a ban?

at file loading on the server it is not necessary.
Likely it meant.

15

Re: How the controler without I twist?

big-duke;
Not under a ban. Simply it is more difficult, than to work with the classical

<input type = "file" name = "file" id = "file"/>

There at once it is transferred both a content and file name and other, all as was in WebForms.
Simply  all it to do manually for .

16

Re: How the controler without I twist?

NickRenziglov wrote:

big-duke;
Not under a ban. Simply it is more difficult, than to work with the classical

<input type = "file" name = "file" id = "file"/>

There at once it is transferred both a content and file name and other, all as was in WebForms.
Simply  all it to do manually for .

And how the user who wants heels of files to select and  them for page and it is joyful to watch of progress of their filling on the server?:-Q

17

Re: How the controler without I twist?

skyANA;
The static picture with the drawn synonym of a word a bolt is given to such user.:D