Expand|Select|Wrap|Line Numbers
- [System.Web.Services.WebMethod()]
- public static string GetServerDateTime(string msg)
- {
- String result = "Result : " + DateTime.Now.ToString() + " - From Server";
- System.IO.FileInfo file = new System.IO.FileInfo(System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["FolderPath"].ToString()) + "\\" + "Default.aspx");
- System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
- Response.ClearContent();
- Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
- Response.AddHeader("Content-Length", file.Length.ToString());
- Response.ContentType = "application/octet-stream";
- Response.WriteFile(file.FullName);
- //HttpContext.Current.ApplicationInstance.CompleteRequest();
- Response.Flush();
- Response.End();
- return result;
- }
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- function GetDateTime() {
- var params = "{'msg':'From Client'}";
- $.ajax
- ({
- type: "POST",
- url: "Default.aspx/GetServerDateTime",
- data: params,
- contentType: "application/json;charset=utf-8",
- dataType: "json",
- success: function (result) {
- alert(result.d);
- },
- error: function (err) {
- }
- });
- }
- </script>
i don't know how to download the file with other methods
Please suggest me if any other methods available or give the correction in the same code.
Thanks to all..