SBirthare
SBirthare

Reputation: 5137

link in excel cause duplicate invocation

Problem Background

In my ASP.net MVC4 web application, we allow user to download data in an Excel workbook, wherein one of the cell contains a hyperlink to a report page. We prepare the link such that when user click the link in Excel, ReportController gets called with parameters, processes the request and return a report summary view i.e. .cshtml page. All works well...

I generate excel using SpreadSheetGear, code snippet that generate link:

rrid = (int.TryParse((string) values[row][column], out outInt) ? outInt : 0);
worksheet.Hyperlinks.Add(worksheet.Cells[row + 1, column],
    PrepareProspectProfileLink((int) rrid, downloadCode),
    string.Empty,
    "CTRL + click to follow link",
    rrid.ToString(CultureInfo.InvariantCulture));

Problem

I just noticed that when I click the link in excel, the same request is sent to the web server twice.

Analysis

I checked using Fiddler and placed a breakpoint in application code and its confirmed that the request is indeed sent twice.

In fiddler, Under Process column I found that first request is coming from "excel:24408" and second request is coming from "chrome:4028".

Also if I copy paste link in Outlook, it invokes request just once.

I understand this indicate, the first request is invoked by excel, when excel is served with html, it knows nothing about how to render it hence handover the request to default web browser which is Chrome on my system. Now Chrome fires the same request and on receiving html, it opens the html page.

Question

How can I stop this behavior? It puts unnecessary load on web server. And secondly when I audit user action, I get two entry :(

Upvotes: 0

Views: 797

Answers (1)

Ondrej Svejdar
Ondrej Svejdar

Reputation: 22074

I'm not sure about excel, but you can handle this weird behavior on web server instead. You can create html page (without auditing) that will use javascript to redirect user to page with real report (and auditing stuff).

If you're concerned just about auditing, you can track requests for report in cache (or db) and consider making auditing entry only if same request for report wasn't fired let's say 5 seconds ago.

Upvotes: 1

Related Questions