remove extension in URL on an iis server - javascript

I have pages set up with razor code to use a consistent layout on every page.
I don't want the pages url to display with the .cshtml tag
How can I do this. I use JQuery, JavaScript, HTML, CSS, ASP.net (web Pages Logic)
EX URL; http:// www.site.com/page.htm
I am new to ASP and server side stuff.
#{
Layout = "~/Shared/_Layout1.cshtml"; <!--i use a _PageStart.cshtml that contains this line for dry purpose-->
Page.title = ""; #*add pages title here*#
}
<!--If you want to add Page specific stylesheets Link them here with HTML tags-->
#section ExtraHeadContent {
}
#section NavBarLinks {
<!--Enter links here for the top navigation bar <a class="topnav-link" href="~/index.html">| Home</a> -->
}
<!--Enter the Pages HTML content here. This will be displayed in the white content div-->
If there are any relevant pages or discussions you've found in the past please share.

The built in routing system within the ASP.NET Web Pages framework allows you to omit the file extension altogether. If you request www.yourdomain.com/YourPage (where YourPage represents a file called YourPage.cshtml), it should work by default. You can read more about it here: http://www.mikesdotnetting.com/Article/165/WebMatrix-URLs-UrlData-and-Routing-for-SEO.
As for replacing the file extension with .htm, I'm not sure that you hope to achieve by doing that. It won't improve SEO. However, one option would be to use a Nuget package called WebPageRouteHandler. I've written about that too: http://www.mikesdotnetting.com/Article/187/More-Flexible-Routing-For-ASP.NET-Web-Pages. Mapping each file individually could be a pain, but you could generate the routes dynamically from a database or from looping through the physical files to reduce the code required.

Related

HTML Page - same top menu (header) and footer in all HTML pages?

I am developing a static website (don't need any server-side support. I have Basic HTML and JAVAscript) which have a number of pages.
all pages have the same top menu (header) and footer.
what is the best practice considering SEO?
I have two options :
Option 1. Should I copy header.html & footr.html code on every HTML page?
Option 2. Should I include header.html & footer.html on every HTML page?
which Option is better? Does any of them affect SEO?
if Option 2 is the right solution then my follow up question is "How to include common header.html and footer.html ?" I don't want to use PHP/ iframe.
For easy client end work , I could have suggested jquery or javascript for client end rendering of header and footer, but you are looking for SEO friendly web pages.
Considering SEO you need to have rendered HTML pages with header and footer so crawlers can read it (and above solution won't work for that as it renders extra stuff after page load). So either you go for copying and pasting header footer to each page or use PHP/.NET etc for server end rendering that will handle header and footer while rendering.
How often do you change the content of the header? When I was starting with web design I used to include the whole menu with/copy paste, and then do search/replace across all files. But this was before PHP and JS were around.
Content-wise, it should be the same. There could be a difference in the number of HTTP requests and load time if you are including something from another file.
These are so small speed differences that I don't think that it will make any difference SEO-wise.
I personally like to use PHP to include content but you have said that this is not an option for you. Depending on whether you want to use jquery, pure JS, or some other way there is a bunch of different approaches.

How do i make a wordpress plugin to work on static websites

I have a wordpress plugin that i want to make work on a simple static website, the plugin is a cloaker so im sure its not wordpress specific and can work anywhere, it contains a php file for the cloaker and a folder with files as seen in the picture picture of the files
Simple way would be to use the plugin on a wordpress page (embed the shortcode in your editor, or more likely create custom page template without footer and header to have a clean page), and use an iframe on your html page to view the content of this page. I would recommend to use the page template because you probably won't need the header and footer of your page.
There are other ways, but you would need to use a php file, not a static html file to make things work.

Multiple ASPX Pages using the same JavaScript / CSS Scripts

I am using the same CSS links and JavaScript scripts on numerous Web Forms ASPX pages on my website. So the head section of my pages are practically the same, bar a few exceptions.
I was told to look at Master Pages for Web Forms.
Is there somewhere I can store the duplicated scripts/links, and call them on each page, rather than placing the links in each head section?
yes you can use masterPage head protion where you have to place links only once and by binding pages to this master page links will get attached with all pages.If you want any other link other than this you can use content place holder in head portion and use that in the particular page

Use a website template in my web application project in VS12

I am creating a web site and I was given a website template that has various html pages and javascript that my website will reference. I wanted to know if this is possible to add those files and reference them in my project or if I am going about this the wrong way.
First time building a website but I have experience building applications, just confused on the right way to go about this.
Add a master page to your website and replace it's html by the html of your template. add a content place holder in it so that controls can be placed in content pages. copy image, css , and jquery(if any) folders in website. if your css and images are not shown in design of master page then replace Image to ../Image in its html and source of css ../(your file name)

Add query string to script tag link in asp.net to break Cache

Hope someone can help me on this. I manage an ASP.Net website and usually update script files and css files very often. I add current time appended into a single string as a query string parameter (eg: profileImage.jpg?123021) which makes the browser to look for the file without getting it from cache.
How can I do the same thing to all script tags and css links from the server side so that it loads the latest version of the file.
Any help appreciated.
Amila
If your asp.net website uses Master Pages, it should be easy to make these changes in the Master Page file. Look a file with the extension .master. If you are not sure how to make the specific edit, post the <head> area from the master page markup in a new question.
MSDN Master Pages: http://msdn.microsoft.com/en-us/library/wtxbf3hh(v=vs.100).aspx
If your site does not use master pages, then you'd need to create some server-side logic that affects the <head> section of the page. Below are some links to related QA's about injecting script and styles from the server side.
ASP.NET: How to (programmatically) attach a <script> tag, containing a link to .js, to <head>?
How to Add script codes before the </body> tag ASP.NET

Categories

Resources