开发者

Redirect with file upload MVC, ASP.NET?

I have a controller that needs to redirect after receiving a file. I have saved the file successfully on the server side. Now, the only things that is bogging me down is how do I redirect to another site while sending the uploaded file that was saved on the server? Any tips? I am desparate.

OK so here it is, first I save the file on serverB:

file.SaveAs(Server.MapPath("~/ImageCache/") + file.FileName);
开发者_如何学CWebClient client = new WebClient();

Then I do the post:

byte[] data;
client.Headers.Set(HttpRequestHeader.ContentType, "image/jpeg");
data = client.UploadFile("http://hostA.com/Search/", "POST", Server.MapPath("~/ImageCache/") + file.FileName); 
return Redirect( WHAT DO I WRITE HERE??);

Need to get to the place where I find the other service showing me the page when it has received the file.


How are you uploading the file? If this is the usual case of an <input type="file" />, you can just return Redirect("new url"); within your action.

Edit:

If you want to relay this to another web service, you don't need to redirect. There should be some sort of upload method defined in the webservice (including what type of webservice would help). You should be able to call that like you would any other webservice method, probably specifying the FileContents byte[] as a parameter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜