User-893317190 posted
Hi hkbeer,
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.
<system.webServer>
<handlers>
//type = "your httphandler's namespace, the name of your assembly"
<add name="excel" verb="*" path="*.xlsx" type="MyWebFormCases.Services.HandlerXslx, MyWebFormCases"/>
</handlers>
</system.webServer>
In your httphandler.
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/vnd.ms-excel";
try
{
//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));
}
else
{
}
}
catch (Exception)
{
throw;
}
}
For more information , you could refer to
https://docs.microsoft.com/en-us/previous-versions/dotnet/articles/ms972953(v=msdn.10)
Best regards,
Ackerly Xu