.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Downloading an xml file in Web App is of type .aspx

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net


Ive created a Web App where it is possible to download an xml file from the server to the client. It works just fine except that the Save Dialog recognizes the file being dowloaded as of type .aspx and the name of the file as being the name of the page I'm on. The page is called Download.aspx and it contains a button that when clicked executes the following code:

                //sends the content to the client
                Response.ContentType = "text/xml;charset=utf-8";
                Response.AppendHeader("Content-Disposition", "attachment, filename=questionnaire.xml");

The save dialog appears and says:

Name: Download.aspx

Type: ASP.NET Server Page, 1,16KB


If I download the file and open it it contains the correct Xml file content and nothing else, so it is working correctly. It just annoys me that it appears to the user that he is downloading the aspx site (and it shows up as such in windows explorer as well) rather than the xml file which is the actual content.

Does anyone know how I can get the save dialog to show the name and type of my xml file rather than the web page?

View Complete Post

More Related Resource Links

Launch CMD File From ASPX Page


My organization uses a CMD file to install updated files for a major enterprise application. Currently, we send out an email to users with a link to the file and instructions to run it, BUT inevitably users don't update their machines until their in field and try to start the app.


We're now liking the idea of using an ASPX page to prompt the users to run the updates and to capture the fact that the updates have been run. I realize that we can't capture the success or failure of the update. But we'd like to capture the user accessed the page.


Is it possible to embed into the markup for the page a link to the file on the local intranet that the users can click on to run the file?

The user accessing the page would capture that they did just that. We'd deal with wether or not the update was actually installed or if it failed later with them directly.

Parser Error Message: Could not load type MasterPage File



Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'wamsilverlight.Web.Wam'.

Source Error:

Line 1:  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Wam.master.cs" Inherits="wamsilverlight.Web.Wam" %>
Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Source File: /Wam.Master    Line: 1

Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4927


All of the following have been tried over and over again:

1.) Delete all existing .dlls

2.) Delete MasterPage File and recreate it.

3.) Delete MasterPage perform a c

>>>How to use javascript function in aspx file?



I have a file util.js and there some funtions in same file.

For example functions name are keyUp, keyDown, isNumeric, isAlphaNumeric

I have used these functions in aspx code behind in a textbox to restrict user that he may not be able to input any special character.

Before, I used the code directly in aspx file but I have do it for different textboxes therefore to avoid much coding in aspx file I created util.js and put all code in this file but how to use these particular functions in aspx file I couldn't find the way.

Anyone have idea. Do share with me.

I used the reference like this:


' Font-Names="Verdana" Font-Size="8pt" Onkeyup= "keyUp(event.keyCode)" Onkeydown="return isAlphaNumeric(event.keyCode);" onpaste="return false;">

Calling parameterized method from aspx file


Hi all,
I have following method
 public string GetYoutubeVideo (string code)
        return "asasdasfa"

Read an XML file, setting uname/pw, Accept, Content-Type

Hi; To read some REST XML data we need to set the username, password, and tell it for the http request Accept: application/xml Content-Type: application/xml Is there a sample anywhere showing how to do this? thanks - daveVery funny video - Reporting as a Metaphor

Get Content type Id in dispform.aspx

I have added a data view web part to a DispForm.aspx of a particular list which displays the data from the child list associated to that particular list item in the parent list. In the Child data view web part I show the list of child items and a hyperlink to create a new child item.  But, the child list has 11 content types and i need to redirect to appropriate newform.aspx,how do i get the contenttypeid so that i can append to the url and redirectPlease remember to mark your question as "answered" if it solves your problem. My SharePoint Blog http://dhireny.blogspot.com

Regarding Ui1 data type parsing in xml file

Hi all, I am sending data to host application in the xml file format given below <communicationData deviceStatus="D0"><communicationData> where "deviceStatus" is ui1 data type. The host application  throws a error " error: parsing "D0" as ui1 datatype ". I have tried to send deviceStatus value in decimal format as well but host application is not resposding correctly. If the hex value does not contain any alphabet then host application respond perfectly fine but if hex value contain any alphbet then host application throws error " error parsing "D0" as ui1 datatype" Can any one please tell me how to convert hexvalue(with alphabet) to Ui1 data types Thanks In advance Ravish Kumar      

Problem in downloading a file code.

hey dere, here is my code.....   void transfer() { string filePath = Server.MapPath("~/download"); string _DownloadableProductFileName = "mob.txt"; System.IO.FileInfo FileName = new System.IO.FileInfo(filePath + "\\" + _DownloadableProductFileName); FileStream myFile = new FileStream(filePath + "\\" + _DownloadableProductFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); string lastUpdateTiemStamp = File.GetLastWriteTimeUtc(filePath).ToString("r"); string _EncodedData = HttpUtility.UrlEncode(_DownloadableProductFileName, Encoding.UTF8) + lastUpdateTiemStamp; Response.Clear(); Response.Buffer = false; Response.AddHeader("Accept-Ranges", "bytes"); Response.AppendHeader("ETag", "\"" + _EncodedData + "\""); Response.AppendHeader("Last-Modified", lastUpdateTiemStamp); Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName.Name); Response.End(); Label1.Text = "hel"; } i have two problems in this code.First while running this code i dont get the file damaged or corrupt. Second problem is dat the code exits at Response.End() and doesnt execute d last line... 

Linking JS file to ASPX page or content page

Hi, I moved my JS functions into an external file "JScript.js", because I'm now using a master page and a content page.But it doesn't work any more, and I can't find why.I tried simply to link a js file to an ASPX file, by adding to the script manager the path of my script, but it doesn't work.Here is my js file (we don't need any special things in it do we?) var step1 = false; function pageLoad() { var accCtrl = $find('AccordionCtrl_AccordionExtender'); accCtrl.add_selectedIndexChanged(onAccordionPaneChanged); } function hideAccordionPane(paneNo) { ... } function changeSelected(idx) { ... } function onAccordionPaneChanged(sender, eventArgs) { ... } function check() { ... }And here is my ASP code: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0

How to change the split view when editing an aspx file

I've been using SPD 2010 more and more over the past few weeks.  However, when there's a navigation bar on the left, toolbox on the right, ribbon above and split view of code and design in the middle, there's just not enough room on the screen - (I have 2 LCDs at 1280x1024).  I can spread the window accross both monitors but that's not much use unless, I can change the split between code and design from horizontal to vertical. Is this possible?  Help apprieciated. Cheers, Bill

Downloading a .pdf file

Hi. I have a link button which the user clicks on it and will download a .PDF file into their PC.It is  just a file for them to download.Currently, I have the following code.Response.Clear()                Response.Buffer = True                Response.AddHeader("content-disposition", "attachment;filename=Savings Account eStatement.pdf")                Response.Charset = ""                Response.ContentType = "application/vnd.pdf"                Dim objSw As New StreamWriter("Savings Account eStatement.pdf")                objSw.Close()                lblMsg.Text = "Your file created successfully"                lblMsg.ForeColor = Color.Green              

Changes in the values of controls of .cs file not reflecting on .aspx webpage while execution.

In my code I am assigning certain values to labels from data reader.While debugging I can see that proper values are assigned but the changes are not reflecting in the end of debug on the webpage that are executing.// My Code// Question.aspx.csusing System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;public partial class Examinee_Question : System.Web.UI.Page{    ExamFunctions ef = new ExamFunctions();    SqlConnection con,con1;    SqlCommand cmd,cmd1;    SqlDataReader dr,dr1;    String QType="";    int ctr = 1;    protected void Page_Init(object sender, EventArgs e)    {        con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True");        con.Open();        con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True&qu

Access Javascript from an aspx file through another aspx file

Hello, So.. I have a file called myFile.aspx which is linked to a js file called myJS.js    There is a file linked to an entirely different frame called theOtherFile.aspx.  I want to access a function is myJS.js called myFunc in theOtherFile.aspxI am not entirely sure how I would accomplish that..I am quite new to MVC2 and JS, so I am quite confused as to how to do this.  Any suggestions would be much appreciated.~Anath

data type problem in import data from excel file


Dear All,

I am importing the data from excel file using following code.

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(strFolderFileName) & ";Extended Properties=HTML Import;"
                conn = New OleDbConnection(connstr)
                Dim strSQL As String = "SELECT * FROM [" & strWorkSheetName & "]"

                Dim cmd As New OleDbCommand(strSQL, conn)

                Dim da As New OleDbDataAdapter(cmd)

Now the problem is if a coulmn vlaue start with a number value like "15" then the other string value like "W15" in that column is ignored in the datatable.

eg. The excel column value     Column1


Help with vb-based aspx file from scratch


Hey, newbie here.

I am making a website from scratch. I know nothing about asp.net, but I want to learn to use it for it's database interoperability. So far, everything I've done has been basic html.

I have SOME experience with VB. I decided to make an aspx  page alone from scratch that was vb based, and all I'd done so far was create a form  in web developer 2010 express.

My html page is cut up into frames, and i tried src'ing one of them to the aspx page. But when I run the frames.html page, the part that's supposed to show the aspx page is showin me this:

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

A name was started with an invalid character. Error processing resource 'file:///C:/Users/xxxxxxx/Desktop/xxxxxx/NewCa...

<%@ Page Language="VB" %>


I don't know what this means. This was the html code given to me when I created the aspx page. So why doesn't it understand it?

Another thing I couldn't find was the vb code page for the aspx while I was working on it IN web develope

Add a "Shared Documents" type documents browser onto an aspx Application Page?


I have an aspx page for a user to fire off a mail merge. I'd like them to choose a .html file from a document library in Sharepoint, then choose a contact list, and then have it fire off the mail merge.

The mail merge part is done and works from a console application with the .html file location hardcoded, and the contact list hard coded.
What I need is a way to add a documents browser onto the .aspx page. I can't see any obvious control I can drop on to achieve this though.

Ideally I would drop on a <Sharepoint:DocumentsBrowser> control, point it at a given ListId in sharepoint, and at runtime Sharepoint would display a nice shared documents type documents browser. Is this possible?

I wrote a book :) http://www.amazon.com/Microsoft-Visual-Studio-2008-Programming/dp/0071604081

url rewrite for images(.jpg file extension not .aspx)



I have stored DB images. and I try to access images using url rewrite. But it is not happaning.

I tried this scott methord. http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx. i tried with Application_BeginRequest, but no use

Basically Client don't want to use .aspx extension for images

Is it possible acess db images with out using .aspx file name extension?  then can anybody tell me how to achieve this!!!!!!!!!!!!

My sample url is "www.sample.com/images/folder/imagefilename.jpg" I want to rewrite to "www.sample.com/images/pimges/default.aspx?file=imagefilename.jpg&cat=folder"



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend