TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bahar N.V1984
NA
18
1.4k
download file with mvc
Nov 3 2015 4:38 AM
hi,
i want to write a sample to download file with ajax and mvc file result
it is this but file not downloaded
//fileresult method
public FileResult ExportExcel(string ID)
{
string timeMark = ID + DateTime.Now.ToString("yyyyMMdd HHmmss");
string cellByCellFilePath = Server.MapPath("~/Files/temp/") + timeMark + ".xlsx";
string fileName ="timeMark + ".xlsx";
return File(cellByCellFilePath, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
//jquery function
function ExportExcel() {
$.ajax({
dataType: "json",
url: urlcontroller,
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({
ID: ID
}),
success: function () {
alert("yes");
},
error: function (xhr, ajaxOptions, thrownError) {
}
, complete: function () {
}
});
// css link
<a onclick="ExportExcel()"> exportexcel</a>
Reply
Answers (
1
)
why it is showing your session is timeout using stateserver
Clear Button When Edit mode view in mvc using Razor view