.net - Using RouteExistingFiles To Block Access To Existing Files Even If No Route Exists?

Mar 28, 2010

In ASP.net MVC 2, I can use routes.RouteExistingFiles = true; to send all requests through the routing system, even if they exist on the file system.

Usually, this ends up hitting the "{controller}/{action}/{id}" route and throws an exception as the controller cannot be found.

I do not want to use that route though (I have only a few URLs and they are specifically mapped), yet I would still like to prevent access to the file system.

Basically I want to Whitelist pages using IgnoreRoute. Is there a built-in way to do this?

My current approach is to still have a route "{*anything}" and generate a 404 when this is hit, but I'm just wondering if something is built-in already?

View 1 Replies


Similar Messages:

C# - Block Access To Files When Using The System.Web.Routing.UrlRoutingModule?

Jan 22, 2010

I'm using the System.Web.Routing.UrlRoutingModule.

With that I'm writing:

routes.Add(new Route(@"cart/add", new RouteHandler("~/Order/CartAdd.ashx")));
routes.Add(new Route(@"cart/delete", new RouteHandler("~/Order/CartDelete.ashx")));

And I also have one route called:

routes.Add(new Route(@"{*url}", new RouteHandler("~/Error/PageNotFound.ashx")));

But if I go directy to /Order/CartAdd.ashx I never enter the routing. It goes directly to that handler. And if I go to /Order/ I get a 403.14 error.

How do I instead catch those urls with the routing?

View 1 Replies

.net - Have A Route Named 'properties', But Receive 404 Error (Detects Folder Exists On Disk)?

Jul 28, 2010

I will try and be brief, I am finding when trying to create a custom route with a name and url of properties that my ASP.NET MVC app is returning a 404 file not found when hitting the route.I have deduced this down to most likely be caused by the fact I have a folder on disk called Properties which is of course a common asp.net folder which is automatically created. I have found someone else who has suffered from this problem on SO, but looks like there has been no resolution, only to name your route something different!

Surely this is an oversight, or there must be a workaround? Obviously there will be many common directories you may need as routes and/or folders interchangeably, some of which we already know like Properties probably can't be deleted! I also understand we need to honor real folders as URLs too, but I feel routing should take priority before looking at folders on disk.

View 4 Replies

Web Forms :: Clear Existing Route Value When Using Response.RedirectToRoute?

Dec 9, 2010

If I have the following routes:

RouteTable.Routes.MapPageRoute("route1", "products/{cat1}/{cat2}.aspx", "categories.aspx");
RouteTable.Routes.MapPageRoute("route2", "products/{cat1}.aspx", "categories.aspx");

And am at this url:

products/door/steel.aspx

I would like to use Response.RedirectToRoute to redirect to "products/tools.aspx".

Response.RedirectToRoute(new { cat1 = "tools" }); redirects to "products/tools/steel.aspx"
Response.RedirectToRoute(new { cat1 = "tools", cat2 = "" }); redirects to "products/tools.aspx?cat2=steel"
Response.RedirectToRoute("route2", new { cat1 = "tools" }); redirects to "products/tools.aspx?cat2=steel"

Basically it seems the existing route values are being used in the redirect instead of what I specify. This behaviour can make sense, since it makes it easy to redirect to a url with only one route value different. But why when I specify it to be empty or specify what route to use does it add the existing value as a querystring argument, and is there a way around this?

View 1 Replies

MVC - Html.BeginForm(). Can Post Back To A Different Route And Keep Existing Querystring Values

Sep 16, 2010

I have a post-only action that has a different route. In my form, I need to post to it, but also keep the querystring values I currently have.

Initial response: /my/first/path/?val1=hello
Needs to post to: /my/other/path/?val1=hello

It seems when I specify a route, it of course only returns the route and doesn't append the querystring values of my original page (for obvious reasons).Is it possible to cleanly append querystring values to my the action attribute of the form tag?

View 3 Replies

Web Forms :: Bulk Insert Records And Update Existing Rows If Record Exists Exception

May 7, 2015

When processing many records starting from 10,000 System.OutOfMemoryExceptio get the error. There would be some way to handle this type of memory error ?.

ASP.Net SqlBulkCopy- Bulk Insert records and Update existing rows if record exists Exception: Out of Memory Exception C# and VB.Net

View 1 Replies

Web Forms :: CSV File - Bulk Insert Records And Update Existing Rows If Record Exists

May 7, 2015

I need a way of doing the following:

I receive data in .csv format. I have a some records on a table, so what I need to do is to check if the data I receive exist on the table of records that I need to match against.

If the record exist, then an email/sms should be sent to notify me that the records has been matched and then that record should be flaged that it has been tested so that I don't test it again as the incoming data are saved.

View 1 Replies

MVC :: How To Route Files With Extensions I.e .txt And .xml

Jul 11, 2010

I have a site that requires the robots.txt and the sitemap.xml be different almost everytime its called. So I need a way to generate the robots.txt on the fly everytime its called. [URL]will hit a controller function and there I will write the return data there. I been looking around and I have no clue how to do this with the extension present.

View 3 Replies

.net - Custom HttpHandler To Block Downloads Of .wmv Files?

Jan 4, 2010

I create a custom http handler to block download of .wmv files e.g. www.pakdev.net/videos/file.wmv (blocked by httpHandler).

But the problem is that now silverlight cannot also stream these video files as they are blocked too.

View 1 Replies

Security :: Custom HttpHandler To Block .wmv Files?

Jan 4, 2010

On my website, www.pakdev.net, I create screencasts to which are streamed through silverlight.

I create a custom handler to block the download of .wmv files from the url like [URL]

But the problem is now the silverlight has also stopped streaming files.

View 1 Replies

How To Have Website Block Access To IE6

Mar 29, 2011

How can I have my website block access to IE6? Redirecting it to a custom error page.

View 3 Replies

Access :: Add Columns To An Existing Ms Access Database Permanently?

Jan 30, 2010

I hava a textbox and button in my project. I want the button on click to add a new column inside the database "Trial.mdb" , table name "table1". The column name will be text typed in the textbox and it will be text type. How could I do that? with a sql code in asp:accessdatasource or in my code behind ?

View 13 Replies

How To Access The Route

Mar 11, 2011

I'm using ASP.Net 4 URL routing on a web forms site.

I have multiple routes to a single page

routes.MapPageRoute("","our-services", "~/Information.aspx");
routes.MapPageRoute("","our-company", "~/Information.aspx");

On the destination page (Information.aspx) how can I tell which route was used to get there, for example was it from our-services or our-company?

View 2 Replies

C# - Block Certain Ip's (users) To Access Website?

Apr 20, 2010

anybody knows of blocking certain users (by IP) from accessing your website (website on asp.net mvc).

EDIT: I know that web-servers can do this as well, but I need this at the application level

View 3 Replies

Download Existing File From IIS Results In File Does Not Exists (404)?

Mar 25, 2010

I have a full working web site that i ported to a new hosting company. In some pages i have links to PDF on the server (they do exist!) On the old server no problem. On the new one when user clicks on the link : error 404 file does not exist.. Should i look in the web.config ? i don't know where to start

View 3 Replies

Web Forms :: Sitemap Ignores RouteExistingFiles / Adds Forward Slash

Oct 13, 2010

i have an up & running site based on asp.net 4 routing everything works perfectly except for one page the dynamic route for this page is [URL] i also have a physical folder in the site named admin at first i was getting a iis error when i tired to access this page. then i discovered RouteExistingFiles=true so now the page shows up whats odd though that the sitempappath is empty as well as another sitemap-based treeview on the page so i checked the page's sitemap.currentnode , which is also empty. why? so more research showed that [URL] is always redirected to [URL] (realize the foward slash at end!)

if i search the sitemap like this SiteMap.Provider.FindSiteMapNode("~/Admin") then it returns the node . but like this SiteMap.Provider.FindSiteMapNode("~/Admin/") [-with fwd slash] it return nothing so the question is: why is "~/admin" always redirected to "~/admin/" and how do i either stop it or make the sitemap ignore final fwd slashes?

View 2 Replies

Security :: To Set EnvironmentPermission/ Block User To Access Web.config?

May 7, 2010

I know a user can use the following code to access the content of web.config
string connectionString = ConfigurationManager.ConnectionStrings["MyConnect"].ConnectionString;

If I set EnvironmentPermission, can I block user to access the content of web.config?

View 1 Replies

Application Block Connection String From Data Access Layer

Jun 4, 2010

I am making use of 3-Tier architecture while making my project. And in Data Access Layer I am making use of application block, but application gets a connection string from web.config; but ClassLibrary of Data Access Layer doesn't contain web config file. How can I access connection string from Data Access layer?

View 5 Replies

Security :: Block Access To Folder (directory) With Authentication Mode = None?

Aug 14, 2010

I have a problem in my asp application. In my application I have an own authentication mechanism so in the web.config file I have <authentication mode="None"/>

Inside the application users can upload files to the folder I've created (App_Files). I would like to give access to the folder only once they are logged in (Session["Login"] is no null).

I dont want not logged in users to be able to access the files over a url address in the browser (like http://<server>/App_Files/Filename.pdf)

View 7 Replies

Web Forms :: Can Access The Route Data From The Destination Page

Sep 8, 2010

Looking at the asp.net v4 URL Routing it's easy to see how to access routing data from basically anywhere in the app.

Via: Page.RouteData.Values["blah"]

Unfortuantely the Route data always is blank by the time i hit the page on my v 3.5 implementation of routing. I was wondering if there was any way to either pass the route values to the final page so i can use them there - i really don't want additional logic in my handler file and i have loads of Routes and don't want many RouteHandlers.

View 3 Replies

Block Direct Access To .aspx Pages Using IIS7's URLRewrite Module?

Mar 30, 2011

I am using IIS7's URLRewrite feature to hide the .aspx extension in my ASP.NET WebForms application's URLs.

I'm using the following configuration:

[code]....

I can now browse to:

[URL]

and this is rewritten to:

[URL]

This preserves the "pretty" url in the browser address bar. I have also updated all my links on the site to use the extensionless URLs.

The problem is that the underlying .aspx pages can still be accessed directly and I'd like to prevent this.

If a user browses to [URL] I'd like it to either redirect/rewrite to [URL], or at the very least just return a "Page not found".

Update:

I managed to get this working by redirecting all .aspx pages to the home directory. This isn't ideal as I'd prefer to send them to the non-.aspx version, but it will do for now.

<rule name="Block .aspx" stopProcessing="true">
<match url=".aspx" />
<action type="Redirect" url="/" />
</rule>`

How do I rewrite and redirect URLs that directly address .aspx pages to my friendly URL format?

View 2 Replies

Access :: No Data Exists For The Row / Column?

Aug 17, 2010

I am having a slight problem with a feature I am trying to get working on a website I am doing. I keep getting the "No data exists for the row/column" error. And the problem appears to be with this line of code:

[Code]....

View 3 Replies

Access :: No Data Exists For The Row / Column

Feb 28, 2011

I have some code with a connection string going to a mdb, the query looks correct to me and I know that the data stored in the table exists but when I run the query in my code it says: No data exists for the row/column.

[Code]....

It has crossed my mind that perhaps the way the data is put into the program is not compatible with the data in the database, I don't know if that is a valid thought though.

View 3 Replies

Access :: Check File Name Already Exists?

May 18, 2010

I am taking backup for mdb file from source location to destination location.While using file.copy() function,how to check whether the folder is already exists or not.If exists means how to replace new one for existing one.Send C# code for replace new one for existing one.

View 1 Replies

Web Forms :: Viewing And Downloading Existing Files

Jan 21, 2010

I want to view the existing files in a directory which is "~/Images". Now the code below works fine and it shows the files (with its name and other details) in this directory very well in a data grid. The name is a hyperlink, but when I click on it, it tries to view the file in "~" (i.e current working directory) instead of "~/Images" and therefore reports the server error as - "file not found".

Also, how to implement if I want the save as option when I click on the file, so that I could save it directory locally instead of viewing it in browser?

VB Code-

Imports System.IO
Partial Class uploaddoc
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dirInfo As New DirectoryInfo(Server.MapPath("~Images"))
articleList.DataSource = dirInfo.GetFiles("*.gif")
articleList.DataBind()
End Sub
End Class
HTML (ASP.NET) Code -
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="uploaddoc.aspx.vb" Inherits="uploaddoc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.IO" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataGrid runat="server" id="articleList" Font-Name="Verdana"
AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"
HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="File Size"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:#,### bytes}" />
</Columns>
</asp:DataGrid>
</div>
</form>
</body>
</html>

View 1 Replies







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