asp.net - Get the actual last modified date for the requested page in WebForms -


i want put last modified date of (the .aspx file responsible for) viewed page footer of web forms site.

i working on default web forms template visual studio 2015 , building project .net 4.5. in site.master, have modified footer so:

<footer>     <p>         page last updated on:         <asp:label id="modyfikacja" runat="server" text="coś nie poszło" />     </p> </footer> 

and modified page_load() method in site.master.cs so:

protected void page_load(object sender, eventargs e) {     string _site = server.mappath(httpcontext.current.request.url.absolutepath);     modyfikacja.text = "(" + _site + ") " + file.getlastwritetime(_site).tostring(); } 

unfortunately, doesn't work way through:

  • when go http://localhost:11111, correctly returns date file path c:\imaginelikeapathheredude\default.aspx,
  • but when go to, say, http://localhost:11111/about, attempts date file path c:\imaginelikeapathheredude\about - ie. web route pasted onto physical root, instead of c:\imaginelikeapathheredude\about.aspx file behind route,
  • (http://localhost:11111/contact.aspx redirects http://localhost:49480/contact , doesn't change output of functions mentioned in question).

there loads of alternative solutions getting file, proposed on web (and on stackoverflow), none of them work, either. if change _site variable to...

  • request.physicalpath, nothing changes.
  • server.mappath(httpcontext.current.request.url.absolutepath), nothing changes.
  • server.mappath(httpcontext.current.request.servervariables.get("script_name")), nothing changes.
  • httpcontext.current.request.servervariables.get("path_translated"), nothing changes.
  • httpcontext.current.request.servervariables.get("script_translated"), exact same file path, \\?\ @ front, , application crashes, since canonical path not valid file path.
  • server.mappath(request.url.localpath.tostring()), nothing changes.

so - how can .aspx file?

ps. there a similar question, seems short, vague , poorly worded - so's similar questions , myself think it's getting .aspx file, while 2 answers think it's getting url.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -