Unable to call action from view int his way in asp.net mvc
I am developing the image upload module for my asp.net mvc application. for that I write code partially in my view page as
//Other html code...
<div id="popuup_div" class="popup_msg">
<form action="/UserProfile/uploadfile" method="post" enctype="multipart/form-data">
<%= Html.Hidden("userIdForFile",Model.UserId) %>
<p>
<label for="ProfilePhoto"><%= Resources.Global.ProfilePhoto %>:</label>
<input type="file" name="pPhoto" />
</p>
<input type="submit" value="upload" /> |<input type="button" value="close" onclick="javascript:$('#popuup_div').hide();" />
</form>
</div>
//Other html code...
But unable to call the action after code get published . why should be this . can somebody help me ?
Edited:
<% using (Html.BeginForm("uploadfile", "UserProfile", FormMethod.Post, new { id = "testform", enctype = "multipart/form-data" }))
{%>
<%= Html.Hidden("userIdForFile", Model.UserId)%>
<p>
<label for="ProfilePhoto"><%= Resources.Global.ProfilePhoto%>:</label>
开发者_开发技巧 <input type="file" name="pPhoto" />
</p>
<input type="submit" value="upload" /> |<input type="button" value="close" onclick="javascript:$('#popuup_div').hide();" />
<% } %>
**Edited**
In firebug i got this text of my HTML with light colored :
I suspect that when you publish the site there is a virtual directory involved. So /UserProfile/uploadfile
is no longer a correct url. To avoid this you should never hardcode your urls like this. I would recommend you using HTML helpers.
So:
<% using (Html.BeginForm("uploadfile", "UserProfile", null, FormMethod.Post, new { enctype = "multipart/form-data" })) { %>
...
<% } %>
精彩评论