Asp.net mvc 3 如何按顺序调用两个动作方法?

Asp.net mvc 3 如何按顺序调用两个动作方法?,asp.net-mvc-3,Asp.net Mvc 3,我有一个表单,其中我需要上传文件运行时并在运行时传递一些数据。 我在下面给出我的代码。这是我的Cshtml <div id="SenMailForm" class="divFlotter"> <div class="divHeader"> Send Resume</div> <div id="BasicJobDesc

我有一个表单,其中我需要上传文件运行时并在运行时传递一些数据。 我在下面给出我的代码。这是我的Cshtml

 <div id="SenMailForm" class="divFlotter">
                    <div class="divHeader">
                        Send Resume</div>

                        <div id="BasicJobDescriptionInfo" class="divInner">
                            <table width="100%">
                                <tr>
                                    <td width="10%">
                                        To
                                    </td>
                                    <td width="90%">@Html.TextBox("txtTo", "", new { @class = "inputBoxLogin_L", style = "width:800px" })
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        CC
                                    </td>
                                    <td>@Html.TextBox("txtCC", "", new { @class = "inputBoxLogin_L", style = "width:800px" })
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        BCC
                                    </td>
                                    <td>@Html.TextBox("txtBCC", "", new { @class = "inputBoxLogin_L", style = "width:800px" })
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Subject
                                    </td>
                                    <td>@Html.TextBox("txtSubject", "", new { @class = "inputBoxLogin_L", style = "width:800px" })
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Attachment
                                    </td>
                                    <td>
                                        <div id="dvAttachments">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Other Attachment
                                    </td>
                                    <td>
                                        @using (Html.BeginForm("StoreOtherAttachment", "Vacancy", FormMethod.Post, new { id = "StoreOtherAttachmentForm", enctype = "multipart/form-data" }))
                                        {
                                            <input class="inputBoxLogin_Small" id="UploadResume" type="file" name="UploadResume" style="width: 200px;" />
                                        }
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                        <input type="checkbox" name="chkSelectAll" value="Bike" checked="checked" onclick="chkSelectAll_Click(this);" />Select
                                        All &nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="checkbox" name="chkSendResumeInZip" value="Car" />Send Resume(s) in
                                        Zip format &nbsp;&nbsp;&nbsp;&nbsp; Priority
                                        <select id="ddlPriority">
                                            <option value="Low">Low</option>
                                            <option value="Normal">Normal</option>
                                            <option value="High">High</option>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                            <br />
                            <table width="100%">
                                <tr>
                                    <td style="vertical-align: top; width: 10%;">
                                        Body
                                    </td>
                                    <td width="90%">@Html.TextArea("txtEmailBody", "", new { style = "height: 250px; width:100%;", @class = "tinyMCE" })
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td style="text-align: right;">
                                        <button id="btnSendEmail" onclick="ActitySendEmail();">
                                            Send</button>&nbsp;&nbsp;
                                        <button id="btnSendEmailClose" onclick="CloseSendEmail();">
                                            Close</button>
                                    </td>
                                </tr>
                            </table>
                        </div>


                </div>

我想在ActivitySendEmail之前执行StoreOtherAttachment。这怎么可能呢?

为什么不将它们放在一个操作中?重定向到仅继续处理似乎效率低下?在StoreOtherAttachmentForm的成功函数中调用ActivitySendEmail AJAX方法。
     public JsonResult StoreOtherAttachment(HttpPostedFileBase
            UploadResume)
                    {

                        if (UploadResume != null)
                        {
                            byte[] tempImage = new byte[UploadResume.ContentLength];

                        }



                        return null;
                    }
    public JsonResult ActitySendEmail(string strTo, string strCC)
    {
       //Doing something
    }

function ActitySendEmail() {
            var dataString;
            var contentType;
            var processData;

            action = $("#StoreOtherAttachmentForm").attr("action");
            if ($("#StoreOtherAttachmentForm").attr("enctype") == "multipart/form-data") {
                dataString = new FormData($("StoreOtherAttachmentForm").get(0));
                contentType = false;
                processData = false;
            }
            else {
                // regular form, do your own thing if you need it
            }
            $.ajax({
                type: "POST",
                url: action,
                data: dataString,
                dataType: "json", //change to your own, else read my note above on enabling the JsonValueProviderFactory in MVC
                contentType: contentType,
                processData: processData,
                success: function (data) {

                },
                error: function (jqXHR, textStatus, errorThrown) {
                    //do your own thing
                }
            });

            var strTo1 = $("#txtTo").val();
            var strCC1 = $("#txtCC").val();
            var strBCC1 = $("#txtBCC").val();
            var strSubjrct1 = $("#txtSubject").val();
            var strEmailBody1 = tinyMCE.activeEditor.getContent();
            var e = document.getElementById("ddlPriority");
            var strPriority = e.options[e.selectedIndex].value;

            if (strTo1.length > 0) {

                $.ajax({
                    url: "/Vacancy/ActitySendEmail",
                    data: { strTo: strTo1, strCC: strCC1, strBCC: strBCC1, strSubjrct: strSubjrct1, strEmailBody: strEmailBody1,
        strSelectedFiles: strSelectedItemsToSendResume, strPriority:
        strPriority },
                    dataType: "json",
                    type: "POST",
                    success: function (data) {
                        if (true == data) {
                            $("#txtTo").val(null);
                            $("#txtCC").val(null);
                            $("#txtBCC").val(null);
                            $("#txtSubject").val(null);
                            tinyMCE.activeEditor.setContent('');
                            $("#SenMailForm").slideUp();

                            $.msgBox({
                                title: "Send Resume",
                                content: "Resume(s) send successfully.",
                                type: "info"
                            });
                        }
                        else {
                            $.msgBox({
                                title: "Send Resume",
                                content: "Resume(s) does not send.",
                                type: "error"
                            });
                        }
                    }
                });
            }
            else {
                $.msgBox({
                    title: "Send Resume",
                    content: "Please provide TO Email-Id.",
                    type: "error"
                });
            } }