MVC Routes: Defining Route Including Subpaths

Jan 4, 2011

Let's say I want to forward all requests at /js/* to a JavaScript controller Index method. In other words, these routes should all invoke JavaScriptController.Index():

/js/root/index.css
/js/user/account/index.css
/js/master.css

What would the route definition be in my Global.asax.cs file? This doesn't seem to work:

routes.MapRoute("JavaScript", "js/{*path}",
new { controller = "JavaScriptController", action = "Index" });

The breakpoint is never invoked during Debug mode with:

public class JavaScriptController : Controller
{
[HttpGet]
public void Index(string path)
{
var browser = HttpContext.Request.Browser;
System.Diagnostics.Debugger.Break();
}
}

View 2 Replies


Similar Messages:

How To Generate A Path / Url From A Route In The Routes Table

Nov 25, 2010

I have an ASP.NET MVC web application, and I've registered a number of routes in my Global.asax.

I would like to know how I can programmatically build (generate a string url) any one of those registered routes from within my Controller.

I did the same thing in Web Forms with .NET 4.0 using Page.GetRouteUrl(routeName, routeParams) but can't figure out how to do the same thing in MVC (I'm an MVC newbie).

View 1 Replies

MVC Routes Adding An Optional Parameter At The Beginning Of A Route

Aug 7, 2010

I have the following routes setup in my route config file. I have a config reader that maps these to MVC-style routes.

[route name="customers" url="customers/{statename}/{marketname}/{pagenumber}"]
[controller name="Customers" action="Display" //route]
[route name="pcustomers" url="{customername}/customers/{statename}/{marketname}/{pagenumber}"]
[code]...

View 2 Replies

Security :: Forms Authentication With Route Handling - Error Routes Not Recognized, Returns To Login

Oct 1, 2010

I just created a small site with form authentication with route handling. Without forms authentication, the pages route just fine. With forms, it returns back to the login page as it is not one of my allowed locations specified in my web.config file.

I know I probably need to write a custom route handler. Does anyone have an example I can follow for this?

View 1 Replies

MVC :: Routes.IgnoreRoute Not Ignoring Routes?

May 25, 2010

I'm trying to prevent direct file requests from being accepted, and have tried this:

[Code]....

None of these worked. I want the rule to exclude any file of any filename in any directory with a matching extension. How can this be done?

View 11 Replies

How To Mix DynamicData Routes With Mvc Routes

Jan 9, 2011

I am trying to create an Area for running DynamicData with scaffolding as an administration part. It's probably working as it should but I can't get the routing to work.

In my global.asax I have the following function to register the routes:

[Code]....

Unfortunately the "best" thing that happened to me so far was that when I check the default tables I get a message about (MetaModel.VisibleTables)

[Code]....

The problem is that I don't know why this is. Is it the routing or something else? Is it perhaps some security thing or can I not put dynamic data inside an area?

The DynamicData folder itself is located in the root of the application since that is the convention it uses and I have no intention to override that.

View 1 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

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

C# - MVC 3 Custom Route Handler - Skip To Next Custom Route Rule?

Mar 14, 2011

Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.

My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?

View 2 Replies

.net - Trouble Defining Bindings Using Ninject?

Mar 28, 2011

having trouble defining bindings using ninject.I am in a standard ASP.NET WebForms application. I have defined an http handler to Inject dependencies in pages and controls (Property injection).Here is what I am trying to do:I am creating a custom combobox usercontrol. Based on the value of an enum on that combobox, I want to be able to Inject a different object in a property (What I am trying to do is a bit more involved than that, but answer to this should be enough to get me going).

View 1 Replies

AJAX :: Got An Error On A Page Defining A Web Service

Feb 26, 2010

I recently upgraded from VS2005 to VS2008. I did a full install of VS2008, then opened my existing project in it. This launched the conversion wizard which successfully converted my VS2005 project to VS2008 and it opened in VS2008 owever, when I first tried to build the solution in VS2008, I got an error on a page defining a web service saying

View 6 Replies

SQL Query Error In Defining Alias For Column

Sep 4, 2010

My following sql query giving me the following error, What does it mean. Am i defining the alias fir column in wring way. Please help me out with this. My error is this and i am putting query just below the error. Error in SELECT clause: expression near 'Year'. Missing FROM clause. Unable to parse query text.

SELECT [tbl_students].passing_year as Passing Year,[tbl_branch].branch_name as Branch_Name FROM [tbl_students], [tbl_course], [tbl_branch] WHERE [tbl_students].course_id=@courseId
AND [tbl_students].branch_id IN(64)
AND [tbl_students].course_id=[tbl_course].course_id AND [tbl_students].branch_id=[tbl_branch].branch_id
AND (@firstYrPercent is null OR [tbl_students].first_year_percent>=@firstYrPercent)
AND (@secondYrpercent is null OR [tbl_students].second_year_percent>=@secondYrPercent)
AND (@thirdYrPercent is null OR[tbl_students].third_year_percent>=@thirdYrPercent)
AND (@finalYearpercent is null OR [tbl_students].final_year_percent>=@finalYearpercent)
AND (@currentDegeePercentage is null OR [tbl_students].current_degree_percent>=@currentDegeePercentage)
AND (@passoutYear is null OR [tbl_students].passing_year>=@passoutYear)
AND (@currentBacklog is null OR [tbl_students].current_backlog=@currentBacklog)
AND (@sex is null OR [tbl_students].gender=@sex)
AND (@eGap is null OR [tbl_students].gapin_education<=@eGap)
AND (@highSchoolPercentge is null OR [tbl_students].highschool_percentage>=@highSchoolPercentge)
AND (@higherSchoolPercentage is null OR [tbl_students].ssc_percentage>=@higherSchoolPercentage)
AND (@grauationPercentage is null OR [tbl_students].graduation_percentage>=@grauationPercentage)
AND (@diplomaPercentage is null OR [tbl_students].diploma_percentage>=@diplomaPercentage)
AND (@noOfAtkt is null OR [tbl_students].number_of_ATKT<=@noOfAtkt)
AND (@validDate is null OR [tbl_students].DOB>=@validDate)

View 1 Replies

LINQ To SQL Defining Where Class Depending On Parameters?

Jan 26, 2010

[code]....

I am going to return an Object depending on the Class and Year params. I want to remove the where condition when the Class and Year parames are null or zero.

View 2 Replies

MVC :: Defining Validation Rules With Data Annotations?

Sep 24, 2010

Defined RegisterModel class - with some validation rules for creating new users, and this works fine.

Then I get this class, strip few properties and wanted to reuse it as UserInfo_Form_Model, for editing user properites.

No changes, just deleted few items, renamed and reused in strongly typed View for editing.

And result of validation is: -

[DisplayName("Name")] works fine, showing correct

[StringLength(20, ErrorMessage = "xxxx...")] - not working, no message showed when suppose to be one

[Required(ErrorMessage = "xxxx.")] - not working, not showing messages when delete required values?

but (ModelState.IsValid) is false when I checked it in controller (it had to be because required value is missing)?

Is it this only partially correct and how this can be?

Well this is a bit frustrating because it cant be simpler than this and I cant make this simple code reuse.

View 3 Replies

Databases :: Defining Index On Table Columns?

Mar 5, 2011

On one of our tables, a default clustered index is defined on the primary key by sql server 2005. The table also contains forign key columns and has got over 2 million rows. There are very frequent INSERT, UPDATE and DELETE functions on this table. Recently some of the SELECT queries which primary operate on the forign keys have become very slow (resulting in application timeout). To fix the problem, I defined an index on one of the primary keys which gave me very quick results. I don't know much about indexes.

1. Since I defined a new index (on the forign key) in addition to the existing default index, what kind of index (clustered or non-clustered) have I defined?

2. What performance impact does it have on the rest of the system? Is it going to break something else?

3. I read about fill factor. What is this and how does it effect the system?

4. Is the new index physically going to make any changes?

5. In case I delete this index later on, will the database return to the existing state or it will be a different state from now?

View 1 Replies

Web Forms :: Make Menu Manually By Defining Items?

Jan 7, 2010

i am just trying to make a menu "manually" by defining menu items, i am also using css adapter for easy styling. I am facing a problem on postback, i am not getting the selected item (there is no item with class AspNet-Menu-Selected), even without css adapter i think. My menu is simple, there is master page, a couple of pages, the menu is on master page. why, and how can i solve this.

View 4 Replies

C# - Defining Status Of Data Via Enum Or A Relation Table?

Aug 20, 2010

I have an application which has rows of data in a relation database the table needs a status which will always be either Not Submitted, Awaiting Approval, Approved, Rejected Now since these will never change I was trying to decide the best way to implement them I can either think of a Status enum with the values and an int assigned where the int is placed into the status column on the table row.

Or a status table that linked to the table and the user select one of these as the current status.

I can't decide which is the better option as I currently have a enum in place with these values for the approval pages to populate the dropdown etc and setup the sql (as it currently using to Approved and submitted for approval but this is dirty for various reasons and needs changed).

Wondering what your thought on this were and whether I should go for one or the other.

If it makes any difference I am using Entity framework.

View 3 Replies

WCF / ASMX :: Use Optional Parameterss In C# While Defining Service Contracts?

Oct 1, 2010

I mean can I do something like this:

[Code]....

and then implement it the same way as below

List<String> GetEmployees(String EmployeeId, String DepartmentID= "00")
{
}

I tried this, but it didn't work. Its always expecting DepartmentID when I tried to use invoke 'GetEmployees' using service reference.

View 7 Replies

Forms Data Controls :: Defining The Series Parameters For An MS Chart?

Feb 25, 2010

I need to defining the Series parameters for an MS Chart.

Using the sample data below is it possible to set the X & Y value types for a graph with all days for the month on the X axis and the total number of visits for each day on the Y. Are MS Charts capable of auto generating the X axis based on the extents of the data dates as well a counting the daily instances?

[code]....

View 1 Replies

C# - How To Load External Data Files Without Defining Path Explicitly

Mar 27, 2011

I have a C# assembly that loads external files. This assembly is used by asp.net website. The following is the code that loads the data files

string dataDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"data"); filePath = Path.Combine(dataDirectory,_fileName);

The component works fine in a windows app, but when I tried to use it in an asp.net website, it fails as the site could not find the data files. And it gives me the following error:

C:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filescmictranslatorsite20a8eddd864b2575assemblydl35bd4a35e8c6f79b6_98eccb01datafile.txt

View 1 Replies

AJAX :: Defining Minimum And Maximum Range In One Slider Control?

Jan 10, 2011

I want to define Minimum and Maximum values in slider control. In slider control examples there is only one value in slider as in [URL]

View 1 Replies

Security :: Use Membership Provider In Forms Application Without Defining An App.config?

Feb 17, 2011

I have a small windows forms application that uses the membership provider that is defined in my app.config file. I want to get rid of my app.config file and initialize the membership provider completely from code. The reason behind this is because I want to be able to dynamically connect to different databases containing asp.net user tables and I want the user to be able to enter the desired database information into a text box at run time. Is this possible or is it required that I have an app.config file?

View 1 Replies

Web Forms :: Entity Framework With Stored Procedure Using Defining Query

Jun 28, 2012

I wrote a defining query

 <EntitySet Name="EntityFramework" EntityType="SEOAnalysisModel.Store.EntityFramework">
<DefiningQuery>
SELECT Keyword, ResultHead ,Year from SeoAnalysis where Year = 2005

[Code].....

And this column value is repetative.

Now how can i get all column value?

View 1 Replies

Web Forms :: Want To Support Defining Property When Declaring The Instance Of This User Control

Jun 10, 2010

I created user control. It exposes string[] public property (it may be List<string> or whatever). I want to support defining this property in aspx code, when declaring the instance of this usercontrol. Something like this:

[Code]....

[Code]....

View 3 Replies







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