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 ?
Thanks
Thanks. I will try to credit the ones who helped but most important is we really do sincerely thanks to all who have helped.
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;
}
}
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Participant
753 Points
2406 Posts
How to put an excel file on my asp.net site in this case ?
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 ?
Thanks
www.developerfusion.com/tools/convert/csharp-to-vb/
Contributor
3500 Points
1300 Posts
Re: How to put an excel file on my asp.net site in this case ?
Dec 21, 2018 02:20 AM|Ackerly Xu|LINK
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.
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
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.