How To: Provide Save File Dialog for an Image Request in ASP.Net

It is the default behavior of the web browsers, when you click on the image link, to open the image and display it over there. There are instances when you might want your users to remain on the page and simply download and save the image after clicking on the image link.

This functionality can be achieved in ASP.Net. Here I am going to show how to:

Create a blank ASP.Net Web Application. Now you have to create a folder to store the image to be downloaded and add and image to it.

Your solution should look similar to this:

Open the Default.aspx and create a HyperLink to the image like this:

<asp:HyperLink ID="hlDownloadImage" runat="server" NavigateUrl="~/Images/image001.jpg?Action=Download">Download Image</asp:HyperLink>

Note that the image URL is having additional parameter “Action” with value “Download”. We will see the utilization of the same in a moment.

now go and add a new file of Type ASP.Net Module ImageDownload.cs to the solution and modify the code as below:

public class ImageDownload : IHttpModule
    #region IHttpModule Members
    public void Dispose() { }

    public void Init(HttpApplication context)
        context.BeginRequest += new EventHandler(context_BeginRequest);

    public void context_BeginRequest(object sender, EventArgs e)
        HttpApplication app = (HttpApplication)sender;
        HttpRequest req = app.Request;
        HttpResponse res = app.Response;
        if (req.Params["Action"] != null && req.Params["Action"].ToString() == "Download")
            string path = req.AppRelativeCurrentExecutionFilePath;
            res.ContentType = "image/jpeg";
            res.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(path));

Modify the web.config file to include following in <httpModules> section:

<add name="ImageDownload" type="WebUploadManager.ImageDownload"/>

You are done. Run the application and click on the Link for the image and you will see the Run/Save dialog. Try removing the Action parameter from the NavigationURL of the hyperlink; image will be displayed on screen as the default behavior of the browser.


In general whenever we need to get physical location of the file in ASP.Net Application, we use Server.MapPath. This is the most commonly adopted method. If you want the file to be located with reference to the path of the current WebPage, then the implementation holds good, but, in case you have to always refer the file from the application root, this method gives you different results. Take the following scenario, where the application directory structure is as follows:

  • Root
    • Data
      • Data.XML
    • ClassA.cs (uses Server.MapPath(“\Data\Data.XML”))
    • ClassB.cs (uses ClassA to get the XML file contents)
    • SubDir
      • ClassC.cs (uses ClassA to get the XML file contents)

In the above scenario the ClassC will fail to retrive the contents in case of the WebApplication is hosted in a virtual directory. The application will work fine if it is a website. So the implementation will not show any errors when we run the application from the Visual Studio. to make it more generic we can replace the Server.MapPath with

System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + @”Data\Data.XML”.

testosterone booster muscle growth


testosterone booster

To study the ability of human spermatogonial stem cells (hSSCs) to proliferate in vitro under mouse spermatogonial stem cell (mSSC) culture conditions. testosterone.

best testosterone to build muscle

Gender contributes to differences in incidence and progression of chronic kidney disease (CKD) and associated cardiovascular disease. To induce kidney damage in male and female Wistar rats (n = 12/group), a 0.25% adenine diet for 16 wk was used. Kidney function (blood urea nitrogen, plasma creatinine, proteinuria) and structure (glomerular damage, tubulointerstitial atrophy, fibrosis, inflammation); cardiovascular function (blood pressure, ventricular stiffness, vascular responses, echocardiography) and structure (cardiac fibrosis); plasma testosterone and estrogen concentrations; and protein expression for oxidative stress [heme oxygenase-1, inflammation (TNF-α), fibrosis (transforming growth factor-β), ERK1/2, and estrogen receptor-α (ER-α)] were compared in males and females. Adenine-fed females had less decline in kidney function than adenine-fed males, although kidney atrophy, inflammation, and fibrosis were similar. Plasma estrogen concentrations increased and plasma testosterone concentrations decreased in adenine-fed males, with smaller changes in females. CKD-associated molecular changes in kidneys were more pronounced in males than females except for expression of ER-α in the kidney, which was completely suppressed in adenine-fed males but unchanged in adenine-fed females. Both genders showed increased blood pressure, ventricular stiffness, and cardiac fibrosis with the adenine diet. Cardiovascular changes with adenine were similar in males and females, except males developed concentric, and females eccentric cardiac hypertrophy. In hearts from adenine-fed male and female rats, expression of ER-α and activation of the ERK1/2 pathway were increased, in part explaining changes in cardiac hypertrophy. In summary, adenine-induced kidney damage may be increased in males due to the suppression of ER-α. testosterone.

too much testosterone in a man

The question of whether, as hormone therapies, spawning agents differ from each other to induce physiological pathways of gametogenesis and oocyte maturation in fish remains important, because it could modify undesirable changes, regulated by endocrine systems of individual fish. A series of experimental treatments were applied to investigate the underlying mechanism(s) in which female bunnei (Barbus sharpeyi) fish respond differently to hormone therapies. Female broodstocks were injected twice (with 12 h interval) by three different treatments namely A, B and C. The treatment A received carp pituitary extract (CPE) + luteinizing hormone-releasing hormone analogs (LHRHα2) (0.5 mg CPE kg(-1) BW for first injection and 2 mg CPE kg(-1) BW + 10 µg LHRHα2 kg(-1) for second injection), treatment B received CPE (0.5 and 3.5 mg kg(-1) BW), and treatment C received ovaprim (0.1 and 0.15 ml kg(-1) BW). Blood samples were collected at four different time intervals, including prior to injections, 6 h after first injection, 6 h after second injection and at the time of spawning, and serum steroid hormones, including testosterone, progesterone and estradiol-17β as well as cortisol, were measured. Results showed significant increases in serum estradiol-17β following all treatments, but the most profound response was found in treatments A and B. Testosterone was higher in larger broodfish than in small-sized broodfish (>1.5 vs. <1.5 kg) in all treatments. CPE led to higher concentration of testosterone rather than two other treatments. CPE also increases the progesterone following first injection and approximately remains unchanged till the end of experiment. Change in progesterone level was only significant after second injection of ovaprim as well as after spawning compared with previous time. Linear regression analyses indicated that cortisol had adverse effects on progesterone and testosterone levels of weight group <1.5 kg. These results suggest that among inducing agents, applied here, CPE can provide more reasonable response in reproduction of female B. sharpeyi. testosterone.

testosterone pills reviews

To determine whether the central nervous system is involved in the effect of Chinese herbal medicine on sexual function recovery in orchidectomized rats. testosterone.

reload testosterone booster reviews

We aimed to investigate the effect and mechanism of icariin on male sexual function. Forty-eight Crl:CD1(ICR) male mice were randomly divided into control, low-, medium- and high-dose icariin group (intragastric administration of 50, 100 and 200 mg/kg/d for 21 days). Mating experiment was then performed at a ratio of 1: 3 (male: female). The mating behaviours of male mice were recorded. The genital indexes and serum testosterone, nitric oxide (NO), hypothalamic dopamine (DA) and 5- hydroxy tryptophan (5-HT) concentrations were measured. The expression of endothelial nitric oxide (eNOS), phosphatidylinositol tallow alcohol 3-kinase (PI3K) and phosphorylated protein kinase (p-AKT) in penile tissue was detected by Western blot. All icariin groups exhibited shorter capture latency and ejaculation latency, increased number of capture and ejaculation, higher capture and ejaculation rate, and higher testicular and prostate indexes compared with controls (p < .001). These groups had higher serum testosterone and NO concentrations (p < .001), hypothalamic DA and 5-HT levels, and eNOS, PI3K and phosphorylated AKT expressions in penile tissue (p < .05). The effect of icariin was dose-dependently increased. Our study suggests that icariin improves the sexual function of male mice, which might be associated with the hypothalamic-pituitary-gonadal axis and the PI3K/AKT/eNOS/NO signalling pathway. testosterone.

tribulus supplement

hgh replacement therapy

pharmafreak test freak review

mega msm

weider whey protein

where can i buy human growth hormone

yohimbe safe

zma primaforce

testosterone replacement options

tribulus terrestris before and after

best over counter testosterone booster

bsn amino x

cellucor p6 results

diet fuel

all natural testosterone boosters

mp assault diarrhea

top testosterone

best time to take zma

altered state

super servings

hgh hormone replacement therapy

what is tribulus terrestris good for

tribulus benefits

vegan zma

where can i buy testosterone supplements

yohimbe 2000 mg capsules

mutation testing in software engineering

resurrect pm ingredients

pure free trial

mutation and cancer

truth about nugenix

best male testosterone

cellucor pm

how to boost hgh and testosterone

best hgh booster

daa test 5 testosterone booster

reviews on testosterone boosters

d ascorbic acid

extreme testosterone booster

aspartic acid sigma

list of hospitals in usa

zma side effects men

tribulus tablets

p6 extreme black side effects

what happened to ronnie coleman

zma and testosterone booster

walmart testosterone supplements

musclepharm t shirt

strongest hgh on the market

c6 testosterone booster

ronnie coleman strength

caltrate calcium and vitamin d

tren bomb side effects

when to take zma for sleep

zinc and magnesium testosterone

best supplements for boosting testosterone

Regular Expression with C#: Part 1

In this tutorial wholesale jerseys you will learn.

  1. Extract Text From The Web pages
  2. Use a special software (Expresso) to make writing Regular Expressions easier
  3. Write and Use Regular Expressions in C#

This tutorial is intended for people who know how to do some basic Regular Expressions and know the syntax of the language. Since there is a lot of material to cover I won’t go over everything.

Till a little while ago I never really thought much of Regular Expressions. I used them a couple of times just to validate an email address or web address etc. It was not till one day I thought of making a web scraping program that would deal with pages from a site and then store all the grabbed information in an xml file.

The need of grabbing the contents came across while studying the RSS technology. In RSS you need to send user a predefined output in XML format with some extra tags. In this tutorial I will not be reaching to that extent, but will give you all an idea about how to just grab the data from the site. Then its upon you, how to utilize the knowledge.

I will take the example of a google search result page, where the results are listed in a well organized manner. We will find out some text from the page for each result and display the result in my own format.

Step 1: Create a web application to host our functionality.

  1. Open Visual Studio 2005
  2. File Menu > New > Web Site
  3. Select ASP.Net Web Site from the listed project templates
  4. Select Language as Visual C# and Click Ok.

You will see the Default.aspx page in the solution explorer, if not add it.

Step 2: Write code to get the desired page source (Google Search Results).

  1. Drag n Drop a TextBox, Button and a Label Control on the Page in design mode.
  2. Rename TextBox1 to txtSearch, Button1 to btnSearch and Label1 to lblResults.
  3. On btnSearch Click event write the following code.
protected void btnGetRating_Click(object sender, EventArgs e)
    if (string.IsNullOrEmpty(txtSearch.Text.Trim()))
        txtSearch.Text = "Google";
    string URL = txtSearch.Text;
    string IMDBData = WebPage.getContents(URL);
    string fullRating = getRating(IMDBData.Replace("n", "").Replace("rn", "").Replace("nr", ""));
    lblResults.Text = fullRating;

Continue reading Regular Expression with C#: Part 1