C# - Outputcaching Vary Byparams In Webforms Understand Route Parameters?

Jul 1, 2010

Does outputcaching VaryByParams in webforms understand route parameters? Such that if I have a route similar to "Content/{filename}/{more}" that I could do VaryByParams="filename" and have it return cached results based on filename and ignore any values in the more?

View 1 Replies


Similar Messages:

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 :: Don't Understand HtmlAttributes Parameters?

Jan 27, 2010

Don't understand htmlAttributes parameters? try this:

[Code]....

[Code]....

How to correct?

[Code]....

View 11 Replies

How To Define A Route That Have 2 Optional Parameters In The Middle Of The URL The Start An End Parameters Are Digits

Jun 7, 2010

I want to define a route that have 2 optional parameters in the middle of the URL the start an end parameters are digits

[Code].....

View 1 Replies

C# - How To Route A Webforms Page In MVC

Mar 25, 2011

I have an MVC page that has a webforms page that it needs to render:

The virtual directory for the webforms page is:

http://mysite/Report/1

File saved:

~/Areas/Accounts/Views/Invoices/Report.aspx?id=1

How do I map this?

I have mapped it to controller:

return Redirect("~/Areas/Accounts/Views/Invoices/Report.aspx?id=1?id=" + id);

But I get an error.

View 2 Replies

.NET Webforms Wildcard Route?

Sep 29, 2010

I'm using asp.net routing in a webforms app.

I would like to achieve the following url format:

http://[domain]/{parent-category}/{sub-category}/{sub-category}

where the right most category is available as a route value.

Currently I have achieved this with the following route:

routes.MapPageRoute(
"category-browse",
"{*category}",
"~/category.aspx"
);

This will pass all of the categories i.e. "trainers/running/nike-running-trainers" so I can grab the last one with a bit of string manipulation.

Is there a better way of doing this?

View 1 Replies

Is It Possible To Have Catchall Followed By Other Parameters In A MVC Route

Apr 29, 2010

I would like to create a route that looks something like this:

routes.Add(new Route("{*url}/{action}.do/{id}", new MvcRouteHandler())

Is this possible? It seems like the catchall has to be last?

View 2 Replies

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

How To Route Legacy QueryString Parameters In MVC 3

Mar 11, 2011

I am using a third party service that does an async callback to a URL I provide to them. So I tell them to use [URL] This must obviously map to an Incoming() method on my StatusController.

However, what I don't have control over is the format of the parameters they call my URL with. E.g. They will do a callback such as: [URL] I want to map this to the parameters of my action method: Incoming(string param1, string param2, int param3)

How do I do this?

View 3 Replies

MVC Route With Array Of Homogeneous Parameters?

Oct 6, 2010

I trying to create routes for a resource with an array of homogeneous parameters.

URL would look like this:

products/category/{categoryId1}/{categoryId2}/.../brand/{brandID1}/{brandID2}/...

And would like an action method would look like this:

public ActionResult GetProducts(IList categoryID, ILIsts brandID)
{...}

where category and brand are independent filters.

I found a solution for similiar task:

[URL]

And wonder if there is no more beautiful solution that allow to use this prototype public ActionResult GetProducts(IList categoryID)

instead of public ActionResult myAction(string url)for action method to avoid splitting the string and casting?

View 1 Replies

MVC :: Custom Route Returns 404 When All Optional Parameters Are Null?

Feb 19, 2010

I get a 404 error when I navigate to the following URL using the route below:

http://localhost:53999/properties/

However, all the following are correctly routed to the List action in my controller:

http://localhost:53999/properties/usa/new-york/manhattan/12

http://localhost:53999/properties/usa/new-york/manhattan

http://localhost:53999/properties/usa/new-york

http://localhost:53999/properties/usa [Code]....

In PropertiesController.cs: [Code]....

It looks like it should just go to the default controller/action,

View 5 Replies

MVC :: Give Multiple Route Parameters In Global.asax?

Mar 19, 2010

[Code]....

here PublisherId is one parameter , i need to pass another parameter like Type in above line. I have tired but json fucntion wont call

View 7 Replies

MVC Action Parameters With Binded Prefix Not Compatible With Url.Route In Global.asax?

Nov 17, 2010

I have a details page containing a form field named UserId. On the same page i have another search form with a field also named UserId.

I am using Html.LabelFor(vm > vm.UserId) and Html.TextBoxFor(sm > sm.UserId) on the two different view models, vm being the view model and sm being the search model. (Yes, the UserId property on the two models has identical names - because they are the same domain property.

When i navigate to the page, the populated UserId on the vm is inserted into BOTH form fields named UserId by MVC. Even the sm.UserId are empty.

That is my initial problem. There are a few ways ti avoid that. My solution was to use the Prefix flag for the sm.

[code]...

My problem is that MVC can't map the Search.UserId (because of the .) to fit the UserId (prefixed with Search) in the action shown above.

So it seems like MVC has a prefix-feature, that are actually nok fully supported through the Route-handler.

Ofcourse i could rename the Search.UserId to Search_UserId, but then the name dosent match the name MVC expects in the recieving action above. (expects Search.UserId) Renaming The UserId property of the search model would fix the issue, but since it is the same value in the domain, this seems like a workaround.

View 1 Replies

.net Webforms Routing Optional Parameters

Sep 23, 2010

I want to add optional parameters in my routing table.For example I would like the users to browse a product catalog like this:http://www.domain.com/browse/by-category/electronics/1,2,3 etc

routes.MapPageRoute(
"ProductsBrowse",
"browse/{BrowseBy}/{Category}",
"~/Pages/Products/Browse.aspx"

View 1 Replies

Passing Parameters To Crystal Report From Webforms?

Apr 1, 2011

i have a report and i want to display it on a webform. Reports without parameters are working nice and fine. Reports with parameters are creating headache for me. this is the code i have written in BindReport method, which is called on page load event of the form.

[Code]....

i have tried variety of things like assigning ParameterFieldInfo to reportviewer control but, it shows me prompt on page load asking for parameter values of the report. i m using .NET 4.0 EDIT i m using push model for crystal reports. does it change the way we can pass parameters to report from asp.net

View 2 Replies

Configuration :: WebForms Routing In 4.0 Multiple Parameters?

Oct 18, 2010

Simple enough I have a search feature I am wanting to impliment Routing for.Here is the routing table for it.

[Code]....

Now I want to set the postback URL for a linkbutton to go to the search page with all parameters filled in but the last one or for that matter any one of the parameters to be left blank

[Code]....

You will see in this example I left the very last one blank. Now when I do that the link does not work. If I fill in all attributes it does workso can anyone tell me how to work around this issue?

View 2 Replies

NET WebForms - Processing String Parameters Across All Pages On Site

Jun 25, 2010

Working on an ecommerce site which will be integrated with a 3rd party vendor--that vendor uses different identifiers for stores than we use internally (i.e. their store ABC123 is our 001-321). I'm researching the best approach to inspect incoming requests for reserved query-string parameters that indicate the request is using their identifiers and map the identifiers back to our identifiers (so if the request is example.com/&theirId=ABC123 I want to transform the request to example.com/&ourId=001-321). To do this mapping I need to inspect the provided ID, execute a lookup against the database or cache, and forward the request to the specified page--limiting the modifications to just the query-string parameters (other parameters will need to be maintained, as with the details of the HTTPHeader, etc). So far I'm researching a few different approaches: Implementing it in a base Page (which already does too much, but has the benefit of our Logging infrastructure and some other injected dependencies) Implementing it in an IHttpModule Using URL RewritingUsing URL Routing (looks like routing isn't what I want, feel free to offer insight if you think it still fits) Performance cost is a consideration: the actual number of times this translation will occur will be very small compared to the number of requests not requiring it--perhaps 1%. However for another integrated site we will perform this mapping on nearly every request--would a different approach be better suited to this scenario from the previous?

View 3 Replies

C# - How To Vary ItemTemplate Inside An Asp:Repeater

Apr 4, 2011

I have a user control which is used to display search results. The HTML for each result displayed will vary based on the type of result being displayed: "contacts" are displayed in one way, "news articles" are displayed in another, etc. There are around 10 different types of results that are all marked up differently when they get to HTML — so I need around 10 or so different templates for individual results that I can choose between based on the current item being displayed.

I'm using an asp:Repeater to display the results, but I don't know how to select the appropriate template within the asp:Repeater <ItemTemplate>. Ideally I'd like the ASP to select the appropriate template to use based upon the object type being passed in via the searchResultsRepeater.DataSource — but unfortunately I can't use switch on type (see this blog entry for C# switch on type). I can however just pass through an enum value for the type of result being displayed.

In the backend C# code I have an abstract inline SearchResult class, and children of that class like ContactSearchResult, NewsArticleSearchResult, etc. The searchResultsRepeater.DataSource would then be bound to a List<SearchResult>. Each SearchResult contains a ResultListingType type field which gives the type of the listing to be displayed.

Attempt 1: using control flow inside the ASP itself

My first attempt was something like this:

<asp:Repeater ID="searchResultsRepeater" runat="server">
<ItemTemplate>
<div class="item">
<% switch (DataBinder.Eval(Container.DataItem, "type")) { %>
<% case ResultListingType.CONTACT: %>
<p><%# DataBinder.Eval(Container.DataItem, "firstName") %></p>
<p><%# DataBinder.Eval(Container.DataItem, "lastName") %></p>
<% break; %>
<% case ResultListingType.NEWS: %>
<p><%# DataBinder.Eval(Container.DataItem, "newsHeadline") %></p>
<p><%# DataBinder.Eval(Container.DataItem, "newsDate") %></p>
<% break; %>
<% Case AnotherTypeOfListing1: %>
<% Case AnotherTypeOfListing2: %>
<% Case AnotherTypeOfListing3: %>
<% Case AnotherTypeOfListing4: %>
<% Case AnotherTypeOfListing5: %>
<% etc... %>
<% } %>
</div>
</ItemTemplate>
</asp:Repeater>

Unfortunately, this doesn't work:

"switch" and "if" both give "invalid expression term" inside the <%# ... %> brackets.
"Container.DataItem" gives "the name "Container" does not exist in the current context" inside <% ... %> brackets.

Attempt 2: setting asp:PlaceHolder's to Visible = False

I found something that looked useful at how to change the ItemTemplate used in an asp:repeater?. I then tried something like:

<asp:Repeater ID="searchResultsRepeater" runat="server">
<ItemTemplate>
<div class="item">
<asp:PlaceHolder ID="newsResultListing" runat="server">
<p><%# DataBinder.Eval(Container.DataItem, "newsHeadline") %></p>
<p><%# DataBinder.Eval(Container.DataItem, "newsDate") %></p>
</asp:PlaceHolder>
<asp:PlaceHolder ID="contactResultListing" runat="server">
<p><%# DataBinder.Eval(Container.DataItem, "firstName") %></p>
<p><%# DataBinder.Eval(Container.DataItem, "lastName") %></p>
</asp:PlaceHolder>
</div>
</ItemTemplate>
</asp:Repeater>

In my ItemDataBound event I did:

Control newsResultListing = e.Item.FindControl("newsResultListing");
newsResultListing.Visible = false;
Control contactResultListing = e.Item.FindControl("contactResultListing");
contactResultListing.Visible = false;
switch (item.type)
{
case ResultListingType.CONTACT:
contactResultListing.Visible = true;
break;
case ResultListingType.NEWS:
newsResultListing.Visible = true;
break;
default:
throw new Exception("Unknown result listing type");
}

Unfortunately this doesn't work because ASP seems to still be running the contents of the PlaceHolder even after I set Visible = false. I get the error "DataBinding: 'usercontrols_ResultsListing+ContactResultsListing' does not contain a property with the name 'newsHeadline'" — i.e. the newsResultListing PlaceHolder is still looking for the "newsHeadline" field, even though that field doesn't exist for the result listing type being displayed.

In fact I've tried a quick test throw new Exception("e"); in my ItemDataBound, and it looks like the "DataBinding" error is thrown even before control flow gets to the ItemDataBound method, so there's really nothing I can do in there to avoid this error.

I suppose I could add every single field to the parent class and leave most of them null in my children, but that seems really ugly.

Is there a way to make this work, or an easier way to vary my ItemTemplate based upon the type of Container.DataItem I'm currently iterating over? I'm very new to ASP so there's likely something simple that I've missed.

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

Can't Set HTTP Vary Header In IIS7 Classic Mode

Jan 16, 2010

First, a little background. I have written a custom HTTP compression module for ASP.NET. My development machine has Windows 7 Ultimate, which comes with IIS7. My production environment uses IIS6.

The problem I'm having is, Resource Expert Droid (redbot.org) tells me that I need to add a header to my response to properly support compression: "Vary: Accept-Encoding"

On IIS7 in integrated mode, it works properly. However, in classic mode, which is how my application ultimately runs, I cannot get my code to output this header using any of Response.AppendHeader(), Response.Cache.SetVaryByCustom(), or Response.Cache.VaryByHeaders.

View 1 Replies

Web Forms :: Clear Cache On User Control With Vary By Id Parameter

Aug 1, 2010

I have a page that deploys a user control to display an article. The page will show a different article depending on the ID parameter fed in via querystring, and there are many thousands of articles in our db. Here is the problem: I need to cache the user control to improve performance. But editors constantly need to go in and make changes/corrections, which they want to appear instantly on the site. Is it possible to clear the cache for a specific article only once it has been edited? ie for the request article.aspx?id=123? If so how would I do this? Otherwise, if the cache is cleared for all our content every time a single piece of content is edited, it will defeat the object of caching in the first place. I have tried using a cache key as recommended here: [URL] However, this apporach suffers from the drawback mentioned above. have also seen that you can set caching up to be cleared by changes to the db. However, the particular table concerned holds content for a number of other sites and would also have the same disadvantage.

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

DataSource Controls :: Need To Store In MS SQL Server 2005 A Vary Large Text In To One Field Of Type Nvarchar?

Feb 13, 2010

I have the following problem: I need to store in MS SQL Server 2005 a vary large text in to one field of type nvarchar(MAX), In spite of the configuration is apparently correct I keep receiving the following message in the exception: "string or binary data would be truncated".

View 1 Replies

Is It Necessary To Understand C# Before Going

Mar 3, 2010

Do I have to get some C# class before taking C# programming lessons?

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







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