开发者

Can ASP.MVC 3 partial view Attach one file?

I have one partial view in my solution that I want to use to send an email. Using this post : Form with attachments upload and email sending

I found a good way to send emails with attachment, but It doesn't work when I use partialView. My Object at my post gets null开发者_开发问答 at Attachment attribute, but it works right when I use View. I also used Ajax.BeginForm and it works right in View, but like Html.BeginForm it doesn't work in PartialView. So, my question is: How can I get one attachment when I use partialView??


You need to look at your rendered html, view source, and look at the id's and names and make sure whatever code you're using is using the same id's and names.


Use firebug to view the actual posted values( Net->HTML->Post->Post tab ). Sometimes posted values are posted as "ModelInstance.PropertyName" rather than just "PropertyName". In which case the only way I've found to retrieve the value is using Request.Form["ModelInstance.PropertyName"]

The source of the post should look something like this. The value of the name="attachment" will give you a clue into a binding problem.

Content-Type: multipart/form-data; boundary=---------------------------132452512814062 
Content-Length: 694 -----------------------------132452512814062 
Content-Disposition: form-data; name="attachment"; filename="new 2.txt" 
Content-Type: text/plain

blah blah blh blah
asdlkjdslakjsd
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜