rename .html to aspx - any issues

ts84zs
ts84zs used Ask the Experts™
on
I already have a working javascript - html5 application on my intranet website ... Default page in that website is index.html

Now, I need  to check who is current windows domain-user logged in. So I am planning  to create ASPX page just to check currently logged in user...  Because in JavaScript there is no way to find out currently logged-in user )  
So I am planning to get userid by using this csharp code -

String username = User.Identity.Name; /// in index.aspx.cs

Now if I change extension of index.html to index.aspx and in index.aspx.cs I write the code above and everything else remains same(like css, javascript code of index.html and other pages)  will my website work in the same way as before
 
thanks a lot...
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015
Commented:
I think you just need to wire it up in a directive at the top of the page. Example:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Abstimmung.aspx.cs" Inherits="Schulsprecher.Abstimmung" %>

Open in new window


Of course if you needed to access any of the controls on the page in the code behind you would need runat="server" on those as well to make them HTML server Controls.

Author

Commented:
Yes, i will write everything required for aspx and aspx.cs code

Only concern is if I keep my js, css, html code the same and create index.aspx and index.aspx.cs (with code related to aspx like codebhind etc) and just copy paste javascript/css/html part of index.html into index.aspx will there be any problems as far as look and feel and javascript-functinality of the page is concerned?

thanks so much
Top Expert 2015
Commented:
Asp.net can render plain vanilla HTML pages just fine. Javascript runs on the client so .net is out of the picture at that point.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
what do  you mean by plain vanilla html pages
My html page is like lot of css, divs etc will it be displayed properly?
Top Expert 2015
Commented:
By plain vanilla I mean html pages that do not rely on server side code to generate markup. No matter how much css, or javascript or what html tags you use, if a web browser can interpret that markup now BEFORE you run it through .net, then it will be able to interpret it AFTER you run it through .net. Asp.net can only act upon markup inside <%> tag blocks, asp.net web controls like <asp:TextBox and HTML controls with the runat="server" attribute value. Everything else is passed through "as is".  If the only thing on your page is a directive at the top then everything below it will be passed through to the client browser.

Author

Commented:
ok got it ... thanks a lot

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial