ASP.NET MVC Update Address Bar With Ajax Link - asp.net-mvc

I'm trying to create an ajax-driven gallery where each photo in a sequence is loaded with an Ajax.Actionlink.
The user can get to any given photo by passing a parameter to the action method, eg: Gallery/Index?photo=100
The problem is that when the user is cycling through photos with the Ajax.Actionlink's the URL is no longer being updated (the way it would be during normal post-backs) so they can't copy paste from the address bar to get back to a photo.
My question is: what is the best way to solve this issue in ASP.NET MVC? One thing I was thinking of was updating the address bar with hashtags, but frankly I don't know if this is a good approach.
I could use some best-practice advice on how to solve this problem. Any suggestions would be much appreciated, thank you.

If you really want to update the address bar with each ajax update there are a couple of jquery / javascript libraries you can use as described in this blog post: http://stephenwalther.com/archive/2010/04/08/jquery-asp-net-and-browser-history
However, the best practice solution is usually not to try and fake something like this (its only going to go wrong). If you want to give your users the ability to share or link to a photo is to provide a field with the appropriate url or permalink to the url that they can copy from. Google maps has a good example of this - if you wanted to share a map with someone else.

I would look into rewriting your routes to include the photo ID in the path.
E.g., /Gallery/Index/100 instead of ?photo=100. This would be why your ActionLink methods aren't working how they should, as the querystring isn't part of the route.

Related

ios navigation routing through URL schemas

Good evening fellas,
I was looking for a routing api to help me navigate through my app using urls. for Instance If I get a schema in a notification to show the user profile I could do someting like /user/profile on the api and get the view controller with the user information.
While searching we found this lib that seems easy enough to use and straight forward
https://github.com/usepropeller/routable-ios
Yet having one option is like having none. Does anyone have any other libraries to suggest so that we can test (play) with them and stay with the one that is most valuable?
Regards,
LSonic

Opencart: Remove page ID path from URL

I'm trying to make my site more SEO friendly and I' noticing that whenever I go to an product through either a tag or a different page (2,3,4 ect) that it adds it to the URL.
For example:
www.wisdomsurvival.com/Guardian-Survival-kit/culinary-can-of-preparedness-seeds.html?page=2
I would like to remove ?page=2 from the path
Opencart 1.5.4
Any help would be greatly appreciated.
EDIT: My main goal is to have one URL for each page instead of multiple paths. For example:
http://www.wisdomsurvival.com/person-guardian-preparedness-package-camping-bug-out
http://www.wisdomsurvival.com/camping-and-bug-out/person-guardian-preparedness-package-camping-bug-out
The first URL is a direct link, the second comes from clicking from a category, the third (not shown because I can only post 2 links) comes from clicking from a subcategory and the fourth (also not shown) from a manufacturer list.
I need to have them all either redirect to the first URL or just go directly to the first URL without redirecting, along with any other URLS such as the ones that have the page ID path or tag path.
I recognise that theme :-)
Where is the ?page=2 coming from as the link works perfectly without it. You need to trace the source of the link. First try the template views and see if it is a simple link edit in the layout that will accomplish what you need.
If not you may find the information is coded in the controller if it is being dynamically generated. Again you should be able to edit the code that generates the link there.
If not you may find that it is in a model that is being called. Again, just find the model and edit the link structure you find there.
The url on your page will only be a reflection of the url you generated somewhere else in order for the link to be followed in the first place.
Usually when I am building with opencart I find the theme modules are often not coded very well in terms of SEO. Fortunately with opencart these things are usually very easy to remedy.
Top trick -> I often stick additional bits into my urls that have no impact on the page generated but Google picks up on as keywords anyway.
If you post your code if you are having problems reformatting the link formats I will have a look for you,
Hope that helps,
Paul.

How can i make the parent url automatically update to a unique url when iframe loads particular content?

Okay, i'm extremely new to this sort of thing, so i am probably using incorrect terminology, but i've been trying to find an answer and can't, so i'm asking here!
I have a website made in Tumblr that opens post content inside an iframe. However, that means my parent url doesn't change according to the iframe content. Is there a way i can cause the parent url to change according to the post inside the iframe? On other sites i have just done this manually but it needs to happen automaically here.
Help! Thanks!
I think you could achieve this on a website using a trick to manually modify the address in the URL bar without reloading the page. See this question for more information. Unfortunately I am not familiar with how Tumblr works internally so I wouldn't be able to say if you can actually use this. But it seems like the only way to achieve what you want.

Track pageviews in Google Analytics on partial url of Grails application

For my Grails application I want to set up Google Analytics to track only "partial" url's. I 'll explain:
a typical Grails url consists of the following parts: domain + application-name + controller + action + id
e.g. www.mydomain.com/myapp/controller/action/12345
As far as I understand for Google Analytics the page to be tracked is identified by the entire url. For my purpose I'm not interested in the id part of the url: I want to know which actions have been performed, but I need not know for which id the action was executed.
And of course I would like a generic solution, because I have multiple controllers and multiple actions... Maybe some kind of filter stating "I want to track pages 3 levels deep (/myapp/controller/action)" would do? Or a filter stating "exclude everything from url after the last /"?
Any help would be much appreciated.
Kind regards,
Pieter
I think this issue is best solved within the realm of Google Analytics, where you can create a specific report that ignores the id-part of the url.
That way you can just use Google Analytics at its easiest and need not make any code changes to your project
There can be several approaches. First thing comes to my mind is taking one of these steps:
Using profile filters (more info)
Generating the same virtual pageviews on each action id (more info)
Using advanced segments tool with a proper condition (page url pattern match) (more info)
Each approach has its pros and cons, choosing proper one depends on the goal you are trying to achieve.
I think this question is best answered by this article.
As the other contributors suggested, I too thought the issue should be resolved in Google Analytics. I clicked around a bit and got hopelessly confused.
Solving the issue within Grails is much much easier. In short the answer is:
in the Google Analytics tracking javascript there is a
"_trackpageview" action
this action can take as parameter the url you want to track
in Grails I can simply add the stuff I want to track:
application/controller/action
my Google Analytics script is in my main template
I just use: _gaq.push(['_trackPageview','myapp/${controllerName}/${actionName}']);
("myapp" should be the name of your application)
(${controllerName} and ${actionName} are generically available
variables in the Grails views)
Hope this will help others.
Thnx for the other answers.

Using Drupal to do what Digg Does

I'm trying to create a site where, like Digg, a user can submit a link and using ajax it attempts to pull the metadata from the page into a title and description field. The user can change either of these fields then submit the content.
Ideally a module already exists. I tried playing around with Feeds, but I'm not sure if I'm looking in the right place.
I probably have to create my own custom module.
Any suggestions? Can I tap into the Feeds API just to parse the url then take the results and do all the mapping myself? Assuming I want to create my own form and bring in my own ajax.
You could probably do that with Feeds, but I think it might be overkill and could be difficult to configure.
You could do what you're looking for in a relatively small custom module using hook_form_alter to customize the submission form, arg() to determine the URL being submitted, drupal_http_request to retrieve the page, then the Form API's #default_value setting to pre-populate the field(s).
The Prepopulate module does a lot of what you're looking for. If it provides hooks (I'm not sure if it does) all you would need to do is add the drupal_http_request, to handle fetching the metadata.
In Drupal it's called Drigg ;). It is supposed to a nice Drupal module to get the functionality of Digg. It will be worth a try I suppose.

Resources