0

On our ASP MVC view we have links to files on our LAN. In IE this works fine, however in Chrome you can click on the link all day and nothing will happen. We're a Microsoft shop, so it seems like some of the Office documents don't play nice with Google's browser.

As a work-around I simply want to create a controller method that will take the location of the file, passed in as a parameter from an Html.ActionLink, and open it. This is my first attmept:

    public void OpenAttachment(string location)
    {
        Process proc = new Process();
        proc.StartInfo = new ProcessStartInfo(location);
        proc.Start();
    }

This will open the file just file, however the web page then goes completely blank as the browser appears to attempt to navigate to the file's location (the LAN address appears in the navigation window).

Does anyone know of either a better method of achieving this or what I need to do to tweak the method I currently have?

7
  • 1
    Why not try and correct the issue with Chrome? can you paste your View? Commented Sep 11, 2013 at 17:32
  • stackoverflow.com/questions/18646202/… Commented Sep 11, 2013 at 17:33
  • Your links are being rendered wrong. Use @html.Raw(link) (From the view) to parse path. Commented Sep 11, 2013 at 17:35
  • @Html.Raw simply places the path as text on the page. Do you mean use it within the ActionLink? Commented Sep 11, 2013 at 17:38
  • Yes try that. The path that is being rendered looks wrong. Its adding ampersands in there. Commented Sep 11, 2013 at 17:40

2 Answers 2

1

Not entirely sure if this is what you're looking for but have you tried a FileResult?

public FileResult OpenAttachment(string location)
{
    return File(location, "Application/{YOURTYPEHERE}");
}
Sign up to request clarification or add additional context in comments.

Comments

0

Simply added a target = "_blank" attribute to the link and used this as a work-around. Would prefer a more elegant solution, however, if one is out there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.