Last post Dec 21, 2018 02:20 AM by Ackerly Xu
Dec 20, 2018 09:29 AM|hkbeer|LINK
I have a ASP.Net site with standard login
I have a local windows application which can get
www.someonething.com/somepath/MyExcel.xlsx file to get the data and this link can be modified.
How can I provide instead an alternative link using links on my asp.net site like
www.myasp.net/something.xlsx that is equivalent to this above but the machine is able to connect only when this pc login to the asp.net site ?
Dec 21, 2018 02:20 AM|Ackerly Xu|LINK
You could register a httphandler to deal with request ending with .xlsx and in the handler you could ensure the request is from local pc.
Below is my code.
//type = "your httphandler's namespace, the name of your assembly"
<add name="excel" verb="*" path="*.xlsx" type="MyWebFormCases.Services.HandlerXslx, MyWebFormCases"/>
In your httphandler.
public void ProcessRequest(HttpContext context)
context.Response.ContentType = "application/vnd.ms-excel";
//ensure the request is from local pc
if (HttpContext.Current.Request.UserHostAddress == "::1")
// write back the xlsx context.Response.WriteFile(HttpContext.Current.Request.MapPath(context.Request.Path));
For more information , you could refer to