Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Solution

  Asked By: Loren    Date: Dec 16    Category: Sharepoint    Views: 706

I found a solution [got the idea after reading some asp.net forum's
postings not similar to what I was doing but the core concept worked] and since
I was posting this to the group, I thought I would send out my final solution
for you all to see in-case you run across a similar issue!! Basically what I had
to do [since adfs was kill it] was to get the IIS variables I needed from the
server about what the user request modify it on the server store it in an object
(asp.net textbox server control object to be exact) and send it back to the
user, once the server render the html for the client to I then grabbed the
values out of the object (now converted into an HTML client side control thanks
to IIS) then use those values in the JavaScript to tell the clients browser to
go to httpS instead of http!!! Happy programming!!

The first section of script is the server side script which gets parsed first
The second section of script is the client side script which gets parsed second
Code:

///////ADD THIS SCRIPT///////// IN BETWEEN THE <HEAD></HEAD> TAGS

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
String _str_RedirectTo = "NOT WORKING";
String _QUERY_STRING = Request.ServerVariables["QUERY_STRING"];
String _REMOTE_ADDR = Request.ServerVariables["REMOTE_ADDR"];
String _SERVER_NAME = Request.ServerVariables["SERVER_NAME"];
String _SERVER_PROTOCOL =
Request.ServerVariables["SERVER_PROTOCOL"];
String _URL = Request.ServerVariables["URL"];

if (_REMOTE_ADDR =="127.0.0.1"
&&_SERVER_PROTOCOL.Substring(0,5).ToUpper() == "HTTP/")
{
_str_RedirectTo = @"https://" + _SERVER_NAME.ToString() +
_URL.ToString();
if ((_QUERY_STRING != null || _QUERY_STRING != string.Empty ||
_QUERY_STRING != "" || _QUERY_STRING!=" ") && _QUERY_STRING.Length > 1)
{
_str_RedirectTo += @"?" + _QUERY_STRING.ToString();
}
_tbx_Redirect_To.Text = _str_RedirectTo.ToString();
}
}

</script>


<script type="text/javascript">
<!--
function _RedirectToHttps()
{
var _RedirectTo = document.getElementById('ctl00__tbx_Redirect_To').value;

if (_RedirectTo != null && _RedirectTo != "vruser")
{
if (window.location.protocol == "http:")
{
window.location = _RedirectTo;
}
}
}
//-->
</script>


///////ADD THIS SCRIPT///////// IN BETWEEN THE <HEAD></HEAD> TAGS

//////ADD THIS ASP.NET TEXTBOX CONTROL TO THE MASTER PAGE/////////


<asp:TextBox Name="_tbx_Redirect_To_Name" ID="_tbx_Redirect_To" runat="server"
visible="true" Width="0px" ReadOnly="True" MaxLength="2083">vruser</asp:TextBox>


///////ADD THIS ASP.NET TEXTBOX CONTROL TO THE MASTER PAGE/////////

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Solution Or get search suggestion and latest updates.




Tagged: