所以,我没有得到我仍然应该在操作中下载文件的内容。
所以,这是我拥有的控制器。一切似乎都很好,除了我从来没有收到任何文件下载客户端。
<HttpPost()>
Function meetingCP(idCont As Integer, idOpp As Integer, schedule As String) As FileResult
Dim id As Integer = 0
Dim iCSFile As StringBuilder = New StringBuilder()
Dim startDate As Date = schedule
Dim endDate As Date = startDate.AddMinutes(30)
iCSFile.AppendLine("BEGIN:VCALENDAR")
iCSFile.AppendLine("VERSION:2.0")
iCSFile.AppendLine("METHOD:REQUEST")
[bla bla bla]
iCSFile.AppendLine("DESCRIPTION:Reminder")
iCSFile.AppendLine("END:VALARM")
iCSFile.AppendLine("END:VEVENT")
iCSFile.AppendLine("END:VCALENDAR")
Dim StreamWriter As StreamWriter = New StreamWriter("C:\MvcApplication4\MvcApplication4\Content\test.ics")
StreamWriter.WriteLine(iCSFile)
StreamWriter.Close()
Return File(iCSFile.ToString, "text/plain", "MeetingRequest.ics")
'Return File(Encoding.UTF8.GetBytes(iCSFile.ToString()), "text/plain", "MeetingRequest.ics")
End Function
这个动作是由ajax调用的。这可能是问题吗?
function meetCP(idCont, idOpp) {
var meetCPSelect = ("#meettime" + idCont);
var dateTime = $(meetCPSelect).val();
$.ajax({
url: '@Url.Action("meetingCP")',
type: 'POST',
data: { idCont: idCont, idOpp: idOpp, schedule: dateTime },
success: function (result) { }
});
};