How do I redirect a browser to a local file in ASP.NET?

后端 未结 2 1190
离开以前
离开以前 2021-01-21 16:34

I want firefox to open C:\\somefile.txt on the local drive. I\'ve tried response.redirect with the \"file:///\" prefix, but it just inserts \"Object moved to here.\" in

相关标签:
2条回答
  • 2021-01-21 16:54

    To be honest I don't quite know why Response.Redirect("file:///aaa") isn't working for you. Without reading the RFC, or testing it myself, I don't know.

    -- Edit:

    Tested myself; definitely doesn't work.

    Failing someone showing you how, you can just write write a link to it, or use some (admittedly lame) javascript (to be written to the client, instead of Redirecting) like so:

    <script language="javascript">document.location = "file:///aaaa";</script>
    
    0 讨论(0)
  • 2021-01-21 17:16

    You can't. Web pages are explicitly not allowed to link or redirect to local content. It's a security measure.

    0 讨论(0)
提交回复
热议问题