MVC :: Prevent File Download With Route Mapping?

Dec 6, 2010

I have a PDF file in a subfolder from my root, and I do not want people to be able to enter the url directly into their browser and be able to open the file. I have tried:

[Code]....

That didn't work though. Basically, any request to ~/Downloads/file.pdf should not be allowed, and should redirect the request to a custom error page that I created.

View 3 Replies


Similar Messages:

Mapping Route And Parameters In MVC?

Mar 29, 2010

In Area VIPUsers I have controller ProfileController and other controllers.

If I want every method in ProfileController to have parameter (id) and every method in other controllers to have parameter (userid and id) how would I map it?

Would it be

context.MapRoute("ProfileMapping", "VIPUsers/Profile/{action}/{id}",
new {controller="ManageUsers", id=""});

and then map a default one for all the controllers?

context.MapRoute("Default", "VIPUsers/{controller}/{action}/{userId}/{id}",
new {action="Index", userId="", id = ""});

If I go to a page on ProfileController and give it two parameters after {action} (VIPUsers/Profile/SomeAction/4/4/), it'd use the second mapped route. Is that correct?

View 1 Replies

C# - End User To Use My Silverlight Media Player Application In Browser To Play The File, Prevent Them From Download To Local Directly?

Mar 4, 2010

I am using VSTS 2008 + C# + .Net 3.5 + Silverlight 3.0 + ASP.Net to develop a Silverlight application (a video media player) in browser and the function is simple, just use MediaElement to play a remote video file.The remote server is Windows Server 2008 + IIS 7.0 + IIS Media Bit Rate Throttling Control.Since the request media URL can be discovered (e.g. from traffic sniffer), and I want to know how to prevent from download directly from the Url? i.e. I want end user to use my Silverlight media player application in browser to play the file, prevent them from download to local directly. Any easy and quick solution or reference code/documents?

View 5 Replies

Prevent IE File Download Warning Or Maintain State After Warning?

Mar 15, 2011

I have an application whereby a user browses to an Ajax enabled page, sets up some filters, and then clicks on download report. When the user clicks on this button, they are redirected to a Download.aspx page, which builds up the report and appends it to the response as binary (the file may either be zip/pdf or excel). The issue I am having is that everytime the user goes to the page and hits the download button the warning message from IE pops up "To help protect your security internet explorer has blocked this site from download files to your computer". This is not a huge issue, but the problem is that when the user clicks this warning to accept the file, it reloads the page, and all my filters are lost, so the user has to set up all the filters to filter out the data they dont want and then re-download the file.

The interesting thing is that I thought I could track the filters using session variables, so that when the page reloads after accepting the warning message it could be restored, but IE for some reason is not loading the page in the way it should, and so the Page_Load method is never fired when IE reloads it after the user accepting the warning, so I cannot restore the filter settings on the page because I have no event to do it from!

I have searched and searched for a solution.. I have tried changing the mime headers - I am using content-disposition tag set to "attachment; filename=report.zip", I have tried changing the mime type descriptions to different things to see if I can avoid the warning but to no avail. I have tried using an iframe but couldnt quite get it to do what I want it to do, the page was still being refreshed..

View 8 Replies

HttpHandlers / Modules :: Set Handler Mapping To Redirect .php File To .aspx File On IIS7?

Mar 15, 2011

Our website used to be a php website, now everything changed to .net, but the customer still want to keep the original php Request url. I want to know How to set Handler mapping on IIS7 to redirect .php file to .aspx file ? In more details, when you click handler mappings on IIS 7.0, what kind of hanlder should you add (add managed handler or add script map or add wild card script map or add module mapping) to redirect .php file to .aspx file?

View 1 Replies

How To Prevent PDF Document From Being Download To Users PC

Oct 28, 2010

How to Prevent PDF Document from Being download to users PC? it can be viewed on browser but should not download the file to PC.

View 4 Replies

Prevent Download Any Files (specially Swf) From IIS Server?

Dec 16, 2010

i have a asp.net website i have some files swf files that i want to prevent downloading them

is there a solution that the IIS can have a passord for downloading the file swf file and i can provide this password in some situations on the server that i can pass this password in the code

so that the swf file can be viewed from my page only as provide the password

but no one can download it using download managers or any other http request that request this swf file

View 3 Replies

Show Download Dialog Box In Case Of File Download - Located On Amazon Server

Jan 4, 2010

i am using amazon s3 service. now i want to show download dialog box in my asp.net application when user come on download page. i am using amazon sdk.

View 1 Replies

HttpHandlers / Modules :: Redirect Shareware Download URL From A File To A Download Page?

Oct 13, 2010

I'm about to submit my pad file to multiple sharware sites but the pad file has to have a direct link to the download file and can't link to a download page which is what I would like to do, so I can track the traffic and get the downloader's email before allowing the download. I am running an ASP.NET site in VB. Is there a way to tell the web app to redirect to a specific aspx page when it receives a request for a specific file?

View 1 Replies

AJAX :: Download LinkButton In UpdatePanel Throwing Error While File Download?

Jun 10, 2013

I have added linkbutton inside gridview to download, below is my code..

protected void lnkDownload_Click(object sender, EventArgs e)
{
try
{

[Code].....

its giving me following error

"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"

View 1 Replies

Web Forms :: Download File Using New Window When Download Button Is Clicked

Sep 2, 2013

I need to download  a .mp3 file from a folder. during download a new blank page should open and after downloading it should close automatically.

View 1 Replies

DataSource Controls :: Importing Xml File Into Sql Server (.sdf) With Mapping File (Sql Server Compact Edition)?

May 10, 2010

I have been searching for some information on how to import my xml file into a series of tables using a mapping file (schema).

View 2 Replies

Creating Mobile Website Page To Download Symbian .sis File To Mobile Unable To Download Properly

Dec 10, 2010

i m creating asp.net Mobile website page to download symbian .sis file to mobile ,but its not geting download properly.its working perfectly on desktop.

View 2 Replies

Web Forms :: Controlling File Name Of The File Opened Directly From File Download Dialog?

Jul 26, 2010

I am downloading file from database using the following code. This code downloads an excel file from the database which has a macro attached to it when it is opened. This macro reads file name of the excel file and uses it for its computation. Everthing works file if user saves the file on his harddisk and then open if but if he directly opens the file from the dialog(by hitting 'Open' button) then file name of the opened excel file comes out be the name of the webform that has the above code and this leads to error in the macro. Is there any option through which i can control the name of the file if user directly opens the file from dialog or the option to disable or remove 'Open' button form the dialog?

[Code]....

View 2 Replies

MVC :: Webforms Route / Implementing Route In Global.asax

Mar 13, 2011

I tried to mix asp.net 4 webfrom and ASp.Net MVC 3. I add required lines in webconfig, but I've issues implementing route in global.asax

Currently I use several routes for webfroms. routs template are like below

routes.MapPageRoute("Node", _
"article/sport/{nID}/", _
"~/article/articleview.aspx")

I encounter error, when I add below lines to global.asax

routes.MapRoute( _
"Defaultss", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
)

I want to know how could I mix ASp.Net MVC routes with webforms routes.

View 3 Replies

.net MVC Routing - Preventing A Route To An XML File With A Constraint?

Feb 8, 2011

I'm attempting to find a way to preventing a user from accessing a specific xml file. I've tried doing...

route "SiteMap",
"SiteMap/siteMap.xml",
new { },
new { isLocal = new LocalHostRouteConstraint() });
[code]...

View 1 Replies

Web Forms :: Retrieving File Path From Route?

Feb 4, 2011

I have an application that I am trying to add url routing to. Part of my application though, looks at the requested page, and looks for a folder that the file requested is in, and applies different rules depending on the folder. For example, the two files

~/Folder1/page.aspx

and

~/Folder2/page.aspx

would have some different rules applied to them because they are in different folders.What I need to do, is get the actual file information from a request when that request comes from a routed url. I do not need the entire file path, just the relative path. Essentially, I am looking to retrieve the value of the third argument in the MapPageRoute method, e.g.

routes.MapPageRoute(
"RouteName",
"RouteURL",
"~/Folder/Default.aspx"

View 6 Replies

MVC :: A Route Named 'Admin_default' Is Already In The Route Collection?

Mar 9, 2010

when i run the app i got this error

A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name

this is my AdminAreaRegistration

[Code]....

View 2 Replies

Route Constraints And Empty Route?

Sep 24, 2010

I have a url that I want to map routing to:

[URL]

where tabvalue is one of: "personal", "professional", "values" or nothing.

I want to map it to a route like:

Member/Edit/{tab}

But my problem is - I don't know how to specify such constraints. I'm trying this regex:

^[personal|professional|values]{0,1}$

but it only works when I use url

[URL]

[URL]

and doesn't work for

[URL]

how to specify the correct constraint?

P.S. I'm not using MVC, just asp.net WebForms

View 6 Replies

Viewing File Using .net / To Copy/download File To Local User Machine And To Open

Nov 16, 2010

In our application, we allow user to upload documents which can be PDF, Doc, XLS, TXT. Uploaded documents will be saved on web server. We need to display link for each document user uploaded and when user click on that link, it should open relevant document. it is expected to have required software to open relevant documents.

To upload document, we use saveAs method of FileUpload control and it works absolutely fine.Now, how to view it?I believe, i need to copy/download file to local user machine and need to open it using Process.Start.For that i need to find user local temp directory. if i put path.GetTempPath(), it gives me web server directory and copy file there.

File.Copy(
sPath + dataReader["url"].ToString(),
Path.GetTempPath() + dataReader["url"].ToString(),
true);

View 4 Replies

Web Forms :: Can't Start File Download From Server Side Using .aspx File In IE7

Mar 26, 2011

This below code i have used in my aspx page for file download.

Response.AppendHeader("content-disposition", "attachment; filename="" + emailAttachment.FileName + "";");
Response.ContentType = "application/octet-stream";
Response.OutputStream.Write(emailAttachment.Data, 0, emailAttachment.Data.Length);
Response.End();

This block of code display Download file Dialog for Open or Save the attached file.It's working fine in Mozila Firefox and IE8 but doesn't display Download file Dialog box in IE 7

View 2 Replies

Web Forms :: Secure File Download / Hide File Path And Location While Downloading Files

Jan 14, 2013

I have made an application where I am displaying the .pdf , .doc , .docx  files. These files are uploading from an Admin Panel.When user place a mouse pointer on download icon provided in front of every file, it shows the complete path where it’s get saved.I want to avoid this path visibility even when user place mouse on download icon and even if it Inspect an element (as most modern browser will have this functionality).

View 1 Replies

IE Errors On File Download Through .ashx File With Caching Turned Off?

Feb 1, 2011

I have a simple 'file download' generic handler which sets the response contenttype and headers before sending the file through the same response.

I also have Response.Cache.SetCacheability(HttpCacheability.server) set in the global.asax.

As I have noticed from various sources, Internet Explorer doesn't like this no-cache setting and gives an error when trying to download the file (requested site unavailable or cannot be found).

I thought maybe I could override this setting in the .ashx page, so I alter the response's cacheability setting to public. This did not solve the issue. removing the line from global.asax does solve the problem but obviously affects the whole site.

Is there a way of setting the cachability just for my generic handler?

View 1 Replies

Intermittent Bug - IE6 Showing File As Text In Browser Rather Than As File Download

Dec 30, 2010

In an ASP.NET WebForms 2.0 site we are encountering an intermittent bug in IE6 whereby a file download attempt results in the contents of the being shown directly in the browser as text, rather than the file save dialog being displayed. Our application allows the user to download both PDF and CSV files. The code we're using is:

HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Disposition", "attachment;filename="theFilename.pdf"");
response.ContentType = "application/pdf";
response.BinaryWrite(MethodThatReturnsFileContents());
response.End();

This is called from the code-behind click event handler of a button server control. Where are we going wrong with this approach? Edit Following James' answer to this posting, the code I'm using now looks like this:

HttpResponse response = HttpContext.Current.Response;
response.ClearHeaders();
// Setting cache to NoCache was recommended, but doing so results in a security
// warning in IE6
//response.Cache.SetCacheability(HttpCacheability.NoCache);
response.AppendHeader("Content-Disposition", "attachment; filename="theFilename.pdf"");
response.ContentType = "application/pdf";
response.BinaryWrite(MethodThatReturnsFileContents());
response.Flush();
response.End();

However, I don't believe that any of the changes made will fix the issue.

View 1 Replies

Web Forms :: Force File Download On Remote File Server

Sep 13, 2010

I'm trying to force a large (200+ MB) file to download that's on a remote server. The problem is that I can't use the "WriteFile()" function, since I'm not using a virtual path. Then, when I try:

Response.AppendHeader("content-disposition",

View 17 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved