I am looking for a solution that will allow me to print generic url for a set of pages.
Example:
For pages - site.com/About/Contact.aspx, site.com/About/WhoWeAre.aspx, site.com/About/Members.aspx etc., user should see only site.com/About/ in the address bar.
Is that something achievable? This site is not SEO friendly and requires users to login before accessing content, also I don't expect site.com/About/ or any internal pages to resolve to any page when typed directly on browser. I am also fine if real url is printed on status bar if the user hovers on the internal links. I don't think URL Rewrite or URL Routing works here. Or may be I am missing something. Using .NET 3.5 and C#.
I am tagging sitecore because I am more interested in sitecore based solution where I have different nodes under About tree and I want users to see only upto /About in the address bar, but I think if it can be done in asp.net, I can figure out sitecore part.
As you are interested in sitecore, I can tell you how we have done custom URL in a recent sitecore build.
You need to have a custom link manager by extending the current LinkProvider.LinkBuilder sitecore class. Then you need to add your custom logic on how you would like the URL by overriding GetItemUrl and BuidlItemUrl to display URL and finally and it in the web.config for sitecore to use your custom link manager.
Absolutely, use the asp.net 4 routing engine.
This will give you exactly what you want:
http://weblogs.asp.net/dotnetstories/archive/2011/01/03/routing-in-asp-net-4-0-web-forms.aspx
EDIT: for 3.5 check out:
Friendly URLs for ASP.NET
The only way to solve this, keeping /About in the address bar, would be to create client-side code that switches out the content based on user selection.
You can do that by loading the About page and then load the content for any child pages using a postback or using ajax calls.
You could also put an iframe on the /About page, and have the navigation links point the iframe to the other pages.
I think you might be able to use the target attribute to target the iframe, or use javascript to change the src of the iframe.
Related
Is it possible to embed only a specific portion inside of a page(i.e. div) on the WebView control in UWP?
The webview doesn't include an address bar and so will only show pages that you load or can be navigated to from those pages. If you can control what is loaded you can show only the pages you wish.
If you don't have control over the HTML of the site, you could prevent access to pages you don't want by handling the NavigationStarting event and canceling the navigation if it's to a page you don't want displaying.
No, assuming by a "portion" of a website you mean a portion within a page. However as Matt said, if you only want to show a certain page, you can of course navigate to the relevant web page and then control what navigation links you allow through his method.
If you did indeed mean only a portion within a page, the options aren't attractive. Theoretically you could pull down the html of a site with an Http request and then parse it to filter out what you didn't want, store it locally, and then load that local page in the webview. However I think it would add significant overhead, could create conflicts with javascript or whatever else the site might be using, among other things. But hey maybe if it's a very targeted use-case you might be able to play with it.
If in your scenario though you also control said website the app is accessing, then I'd just enable specific URLs to offer up the desired versions of your site when the app requests 'em.
Note 100% sure, but i can give a hit to embed external part of a any html content to a website opened in webview control.
var result = await this.webView.InvokeScriptAsync("eval", new[] { "document.documentElement.outerHTML;" });
string result = await this.webView.InvokeScriptAsync("eval", new [] {"document.getElementById('tablePrint').innerHTML = myTable;" });
Add HTML content through java script.
Hope that will help
I'm trying to be able to determine which page url the user is loading from the master page.
So far I've been able to use
this.Request.RawUrl
to get the path of the page itself, which works fine for most cases.
However in this particular website, we use a lot of complicated routing, so something like (say)
/Product/5/2/Purchase
might redirect to /Purchase.aspx?ID=5Type=2
of which I'd want the actual aspx file path.
I've also tried this.Request.PhysicalPath, but that doesn't give the route and basically just appends the path the user requested to the virtual directory.
So how can I do it?
An asp.net Page treats a master page as just another control.
So if you want to get the page, you can always use the Page property provided by the MasterPage class.
I used this and worked :
Page.ToString().Replace("ASP.","").Replace("_",".")
I'm building SPA application using Backbone.js and as its back-end I want to use ASP.NET Web API. I need only one page and this fact brings me a lot of confusion.
ApiController returns json response and as far as I understand there's no need in asp.net-specific views at all. Am I right?
Can I use plain html for my main page? Or should I use *.cshtml and put a call to RenderBody instead?
If choose the first option then how will I handle validation?
Thanks!
Well the trick is that if you want search engines to be able to index your page, or people to be able to share to Facebook with a custom icon/description, etc you'll need to serve back static HTML -- none of those bots are able to run your javascript to render the page as the browser does.
If you're uninterested in this, then yes, you can completely avoid RenderBody.
The way I create my menus is causing a slight problem. I define the style in my style-sheet and create a module with html in it, here's an example of the HTML:
<ul class="cmenu">
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
<li>Link4</li>
</ul>
My reason being I need multiple menus through out the site all with different links (much more simple than using dnn:NAV with options) and it's working very well.
But trying to create a link to a user profile in this way doesn't seem possible. When visiting my user profile for example I am taken to this link: "../UserProfile/tabid/57/userId/1/Default.aspx" which means to me that DNN is dynamically creating the link and the page is created from the provided link. Please correct me if I'm wrong here.
Also I would like to create new input fields, how do I go about this?
I've been developing in PHP/HTML/CSS/JS for years now, ASP.NET is quite new to me and I couldn't find anything on the subject, thus my questions.
I'm very familiar with C# and Visual Studio, I would like to use these tools to extend on the current Users and Roles structure if possible.
Thanks in advance!!
The URL for the profile is generated server side using the NavigateUrl method within the core.
To solve your HTML module issue in a primitive manner you could enable token replacement and use [User:UserID] as a token in the URL (Replace the 1 with the token in your example).
However, that doesn't work well for unauthenticated users as it will try to take them to -1. Honestly creating a menu might result you to create a custom module for it.
im starting the pseudo code of a new site, and want it to be as SEO friendly as possible.
the site i am creating is a booking agency site with c# and asp.net. essentially bands will register on the site with their availability and other info, and fill out their profile information with images etc. this info will be stored in a db.
creating this is not a problem, but i want the site to be a SEO friendly as possible.
I know google loves huge sites with great content. And all of these profile pages would be an excellent addition to my site for seo purposes. i also hear that google cannot see dynamically generated content when crawling a site.
i want to find a method of coding these pages, so google can see the content when it crawls them.
i need a pointer in the right direction for a solution for this. nothing is off limits - i will basically code my entire site around this principle, i just have no idea where to start looking for a solution. im not looking for a code solution, just what i should be researching to solve this issue.
Thanks in advance
i also hear that google cannot see dynamically generated content when crawling a site.
Google can see anything you can retrieve via http GET request (ie: there's a specific URL for it) and that someone either linked to or is listed in a published xml site map file.
To make sure that your profile pages fit this, you will want to make sure that profiles are all rendered via a single asp.net *.aspx file that determines which page is shown via a url parameter. Something that looks like this:
http://example.com/profiles.aspx?profile=SomeBandName
Now, you probably also want a friendly URL, that looks like this:
http://example.com/profiles/SomeBandName
To do that, you need to set up routing.
In order to crawl and index your pages by google or other search engine properly. Follow the following guidelines.
i: Page title must be precise and according to content available in page.
ii: Page url should be user friendly.
iii: Content is king (useful content)
iv: No ajax or javascript oriented way to load contents.
v: No flash or other media files. if exist must have description via alt tag.
vi: Create url sitemap of all static and dynamically generated contents.
vii: Submit sitemap to google and keep tracking how google crawl and index your pages.
fix issues contineously if google found via crawling.
In this way your most pages and content will be index properly and fastly.
I'd look into dynamic URL Rewriting.
Basically instead of having one page say http://localhost/Profile.aspx you'll have a bunch of simulated urls like
http://localhost/profiles/Band1
http://localhost/profiles/Band2
http://localhost/profiles/Band3
etc.
All of those will then map to back to the orgial profile.aspx page with a parameter so internally in your code it would look like http://localhost/Profile.aspx?Name=Band1, http://localhost/Profile.aspx?Name=Band2, etc
Basically your website appears to have a bunch of pages for each band but in reality they are all getting mapped back to the same asp.net page but have different parameters.
This is article I read about it some time back. http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
i also hear that google cannot see dynamically generated content when crawling a site.
you could create a sitemap.xml with the urls pointing to the dynamic profile pages. using google webmaster tools you can submit and monitor the crawling progress.
you may also create an index page or something similar ('browse by category' pages) that link to matching profile pages.
a reference for seo I regularly use is http://www.seomoz.org/learn-seo