asp.net difference between accessing as local machine or remote client - asp.net

We developp an web application in asp.net Framework 4.7, and we have a difference between accessing the application from the local computer (localhost, or direct name make no difference) and from a remote computer.
The form action is not show with the same information. From the local machine, i get this :
<form name="aspnetForm" id="aspnetForm" action="/MediOnlineNet/(S(id55ddmoixefhknices1zwj0))/DefaultPopup2011.aspx?ppname=_MOPPAG_undefined&Mod=1&0&_MOPPAG_undefined&PPID=254&caller=6&agndPatientId=0&agndContactInformationId=0&numAgenda=5081&numResponsable=10746&typeContact=0&canSeePrive=1&ctrlID=ctl00_CPH_ctl00_Uc_agnd_ctactAff_011&contactName=&contactVorName=&contactDate=&contactNoPatient=" method="post">
and from an remote computer, I get this :
<form name="aspnetForm" method="post"
action="/MediOnlineNet/(S(yevu1jhfwkrqc3wsx4ag3cot))/DefaultPopup2011.aspx?PPID=258&ppname=_MOPPAG_undefined&Mod=1&isModal=0" id="aspnetForm">
And I don't understand why I don't get the same information in each execution.
Any help on this problem ?
Thank you and regards
Philippe RITTER

This is a sample wich show our problem with Request.Url.PathAndQuery
Run this with Default.aspx?tutu
When you click on the second button, on a server, you will get :
trans
/Test/Default.aspx?trans
But if you run it on a dev machine, you will get :
trans
/Test/Default.aspx?tutu
Which in this case, is a false response
Default.aspx :
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:button runat="server" text="?trans Preserve:TRUE" OnClick="Unnamed4_Click" style="height: 26px" />
<asp:button runat="server" text="?trans Preserve:FALSE" OnClick="Unnamed3_Click" style="height: 26px" />
<asp:button runat="server" text="Preserve:TRUE" OnClick="Unnamed1_Click" style="height: 26px" />
<asp:button runat="server" text="Preserve:FALSE" OnClick="Unnamed2_Click" />
</div>
</form>
</body>
</html>
Default.aspx.vb :
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub _Default_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Response.Write(Request.QueryString)
End If
End Sub
Protected Sub Unnamed1_Click(sender As Object, e As EventArgs)
Server.Transfer("Default2.aspx", True)
End Sub
Protected Sub Unnamed2_Click(sender As Object, e As EventArgs)
Server.Transfer("Default2.aspx", False)
End Sub
Protected Sub Unnamed4_Click(sender As Object, e As EventArgs)
Server.Transfer("Default2.aspx?trans", True)
End Sub
Protected Sub Unnamed3_Click(sender As Object, e As EventArgs)
Server.Transfer("Default2.aspx?trans", False)
End Sub
End Class
Default2.aspx :
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Default2.aspx.vb :
Partial Class Default2
Inherits System.Web.UI.Page
Private Sub Default2_Load(sender As Object, e As EventArgs) Handles Me.Load
Response.Write(Request.QueryString)
Response.Write("<br>")
Response.Write(Request.Url.PathAndQuery)
End Sub
End Class

Related

How to get the value of an HTML element attribute that added from code behind?

I have added an attribute isAdmin to an HTML tag as below:
Partial Class Controls_View_ViewOrder
Inherits System.Web.UI.UserControl
Protected Overrides Sub OnInit(e As EventArgs)
Dim isAdmin = Page.RouteData.Values("UserAdmn")
rowMenu.Attributes.Add("isadmin", isAdmin)
End Sub
End Class
Trying to get the value of isAdmin by JavaScript as below:
<div class="rowMenu" id="rowMenu" runat="server"> </div>
.
.
.
let isAdmin = document.getElementById("rowMenu").getAttribute("isadmin");
but I got the below error:
When I try to get the value of isAdmin I got error
The issue is with this line:
<div class="rowMenu" id="rowMenu" runat="server"> </div>
Please write the code in this way:
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Scrap._Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="rowMenu" id="rowMenu" isadmin="<%= Page.RouteData.Values("UserAdmn") %>" > </div>
<script type="text/javascript">
let isAdmin = document.getElementById("rowMenu").getAttribute("isadmin");
alert(isAdmin);
</script>
</div>
</form>
</body>
</html>

ASP.NET Web Forms call embedded VB Code from another aspx. page

I got a Project where somehow an Method is called from another aspx.page. I want like to know how this work.
For instance, in my Foo.aspx I got this:
<script runat="server">
Sub ShowHint()
some code
End Sub
</script>
in Bar.aspx I got this:
<script runat="server">
ShowHint()
</script>
But how does this can even work? I dont get it.
You can use JavaScript (AJAX) to get the data from a different page.
It is easy to do with the jQuery Load function.
You can also define classes where you can define subs of function which you can call from every webpage.
Is the webpage inside of you project?
An easy example: I have a file test.aspx and I want to load some data from test2.apsx. To load the data I use jQuery.
Here is test.aspx
<%# Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//$("#presenter").load("test2.aspx" ... = loads the content of test2.aspx into the div with id = presenter
//$("#presenter").load("test2.aspx #content" ... = loads onlay the content of the div with id = content from text2.aspx
//{ message01: "Hello", message02: "world" } = are the paramter I pass to test2.aspx
$("#presenter").load("test2.aspx #content", { message01: "Hello", message02: "world" }, function () {
//here you can place code which will run after the load is completet
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="presenter"></div>
</form>
</body>
</html>
Here is test2.aspx
<%# Page Language="VB" AutoEventWireup="false" CodeFile="test2.aspx.vb" Inherits="test2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="content" runat="server">
</div>
</form>
And the code from test2.asp
Partial Class test2
Inherits System.Web.UI.Page
Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
Dim msg01 As String = Request("message01")
Dim msg02 As String = Request("message02")
Me.content.InnerHtml = msg01 & " " & msg02
End Sub
End Class
Ok I got this. Just have to include my "Helper" aspx-file in to another aspx-File:
<!--#include virtual="somefilename"-->

User Control doesn't display in master page

I am working on a old ASP.NET project application.
I have to add a notification menu.
To achieve this, I have created a User Control which contains :
ComposantNotificationMenu.ascx
<%# Control Language="vb" AutoEventWireup="false" CodeBehind="ComposantNotificationMenu.ascx.vb" Inherits="extranet.Composant.ComposantNotificationMenu" %>
<ul class="ttw-notification-menu">
<li id="projects" class="notification-menu-item first-item">
Mes derniers évènements
</li>
</ul>
ComposantNotificationMenu.vb
Namespace Composant
Public Class ComposantNotificationMenu
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
End Namespace
Extranet_PageMaitre_Base.master
<%# Master Language="VB" CodeBehind="Extranet_PageMaitre_Base.master.vb" Inherits="extranet.Extranet_PageMaitre_Base" %>
<%# Register TagPrefix="GeneriqueComposant" Namespace="extranet.Composant" Assembly="extranet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Entete" runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<asp:ContentPlaceHolder ID="cphEntete" runat="server" />
</head>
<body <%If Not Me.EstPageAccueil Then%>class="formulaires"<% end if%>>
<div id="divComposantMenuNotification">
<GeneriqueComposant:ComposantNotificationMenu ID="ComposantNotificationMenu" runat="server" Visible="true" />
test
</div>
<asp:ContentPlaceHolder ID="cphCorps" runat="server" />
</body>
</html>
The User Control Load event is handle but nothing is display on the screen.
I really have no idea.. I already develop other component but never in a master page. Is that the problem ?

Opening a new window from a parent window in IE clears parent window's cache

I have a web app that opens a new window when a link is clicked. As soon as I do that though, my browser's cache is cleared. If I do not click the link, the cache is still there.
I have tried both the standard target="_blank" and window.open approach and they both result in the cleared cache.
Here is a reference to someone else encountering the same issue, but with no solution.
http://www.pcreview.co.uk/forums/problem-new-window-clears-cache-t693284.html
Any idea as to why?
IE 7 and 8
This is working for me, try out and let me know:
Html Page 1(Parent):
<%# Page Language="VB" AutoEventWireup="false" CodeFile="wpop1.aspx.vb" Inherits="pruebas_wpop1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="PRIVATE" />
<title>Parent</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server"></asp:TextBox>
<a href="wpop3.aspx" target="_blank" >Popup</a><br/>
<asp:Button runat="server" Text="Button" />
</div>
</form>
</body>
</html>
Codebehind Page 1:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.ExpiresAbsolute = DateTime.Now.AddDays(2D)
Response.Expires = 7200
Response.CacheControl = "PRIVATE"
End Sub
Html Page 2(PopUp):
<%# Page Language="VB" AutoEventWireup="false" CodeFile="wpop3.aspx.vb" Inherits="pruebas_wpop3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>PopUp</title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is the Popup Window.
</div>
</form>
</body>
</html>

why Context.RewritePath method not work on iis

I have an asp.net3.5 website.want to deploy this site on iis.After deploy my default page can not redirect to another page.Need help to understand why page not redirect
My default page is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("hello")
Context.RewritePath("~/asp/Default.aspx", False)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Need help why Context.RewritePath this method not working.my server version is windows server 2008 r2,iis-7.0 ,web site develop on 3.5
If have any query plz ask ,thanks in advanced.
This needs to be in your globals.acsx page, under begin_request

Resources