Some specific Special Characters are getting blocked in my server - c#

I have a problem with my LIVE Server IIS, which I am not facing in my local server IIS. The characters like '|| ||' are getting blocked in my server, when those are present in any textboxes. The server is allowing if the single character is present '|'. Unable to find the correct reason for this. Only if the above specified characters are present in any of the text boxes in the page, then page redirection is not happening. Can any one has already faced this problem, please help me in solving this. If I remove the characters from text boxes, then the page redirections are happening perfectly.
EDIT :
The page from client side is not going to server side, in a single shot the button events are getting blocked and not working. After removing the above mentioned special characters, the button events are firing in the page. Its happening only in my LIVE server, but not in my local. This has been happening from recently before everything was working fine, hope some of my DBAs has changed/enabled some configuration in IIS, but don't know what is that? Please, help.
<script type="text/javascript" language="javascript">
function ValidateFilegrid()
{
document.getElementById('<%=HidValid.ClientID %>').value = "";
var gridView = document.getElementById('<%=GVUploadedDocs.ClientID %>');
for (var i = 1; i < gridView.rows.length; i++)
{
var radio = gridView.rows[i].getElementsByTagName('input');
var selectedvalue;
for (var j = 0; j < radio.length; j++)
{
if (radio[j].checked)
{
selectedvalue = radio[j].value;
break;
}
}
var inputs2 = gridView.rows[i].getElementsByTagName('button')[0];
if (selectedvalue != "Yes")
{
var inputs = gridView.rows[i].getElementsByTagName('input')[0];
if (inputs != null)
{
if(gridView.rows[i].getElementsByTagName('input')[1].value.length > 3)
{
if (inputs.value.length<3)
{
alert("Enter File Validation Remarks !!");
return false;
}
else
{
document.getElementById('<%=HidValid.ClientID %>').value ="N";
}
}
}
}
}
return true;
}
</script>

Related

Exit Chat Window When Finished In Unity

I'm trying to build an interface so I can load a chat window with
messages I can read in the window. The user presses enter and the message index is incremented
so the next message is displayed. After the last message is displayed for
e.g. lvl 7, event 1 I would like the window to close.
The 3 parameters are the level, event, messageindex.
What happens is I don't see the chat window and no messages are
displayed in the window. How can i modify the algorithm so
that I read all the messages for the level and event and then
the window closes properly?
...
Debug.Log("File size is" + sizeoffile);
for (int i = 0; i < sizeoffile; i++)
{
if ((storyitemData["storyline"][i]["event"].ToString() == eventno.ToString()) & (storyitemData["storyline"][i]["level"].ToString() == levelno.ToString()) & (storyitemData["storyline"][i]["index"].ToString() == msgindex.ToString()))
{
Debug.Log("read message was called with message index " + msgindex + " and the content is " + storyitemData["storyline"][i]["content"].ToString());
//check that this is right
txtlbl.GetComponent<Text>().text = storyitemData["storyline"][i]["content"].ToString();
}
else if ((storyitemData["storyline"][i]["event"].ToString() == eventno.ToString()) & (storyitemData["storyline"][i]["level"].ToString() == levelno.ToString()) & (storyitemData["storyline"][i]["index"].ToString() != msgindex.ToString()))
{
msgindex = 1;
chatwindow.active = false;
}
}
Example JSON
{
"storyline":[
{
"level":1,
"event":1,
"index":1,
"content":"hello"
},
{
"level":1,
"event":1,
"index":2,
"content":"yes I saw that"
},
{
"level":7,
"event":1,
"index":1,
"content":"can I buy a sandwhich?"
},
{
"level":7,
"event":1,
"index":2,
"content":"thank you"
},
{
"level":7,
"event":1,
"index":3,
"content":"Salt please"
},
{
"level":7,
"event":2,
"index":1,
"content":"Java was"
},
{
"level":7,
"event":2,
"index":2,
"content":"my first language"
}
]
}
There are numerous ways you can handle this and without more code is hard to determine exactly what your setup is. All you have really shown us is that you are passing in a specific index to the list but for some reason still iterating over a list with a size of sizeoffile which is not mentioned at all.
I am also not sure if you intended this, but in your if conditionals, you are not using a && AND operator, but a bit-wise & AND operator, which is different.
You can simply add another conditional check first to see if the current index you are reading is about to exceed the container type you are using.
if((storyitemData["storyline"].Count) <= msgindex)
{
// we reached the end of the container, so disable our chat window
}
else if((storyitemData["storyline"][i]["event"].ToString() == eventno.ToString()) & (storyitemData["storyline"][i]["level"].ToString() == levelno.ToString()) & (storyitemData["storyline"][i]["index"].ToString() == msgindex.ToString())))
{
...
}
If what I have mentioned does not work, please add more detail to your question, and a bit more code would not hurt either. Adding the original container of the structure you are serializing to JSON would help. Is there a reason you are serializing an entire chat log to JSON to pass around your game?

"The process cannot access the file because it is being used by another process." with SystemReader

I have no coding experience but have been trying to fix a broken program many years ago. I've been fumbling through fixing things but have stumbled upon a piece that I can't fix. From what I've gathered you get Alexa to append a Dropbox file and the program reads that file looking for the change and, depending on what it is, executes a certain command based on a customizable list in an XML document.
I've gotten this to work about five times in the hundred of attempts I've done, every other time it will crash and Visual Studio gives me: "System.IO.IOException: 'The process cannot access the file 'C:\Users\\"User"\Dropbox\controlcomputer\controlfile.txt' because it is being used by another process.'"
This is the file that Dropbox appends and this only happens when I append the file, otherwise, the program works fine and I can navigate it.
I believe this is the code that handles this as this is the only mention of StreamReader in all of the code:
public static void launchTaskControlFile(string path)
{
int num = 0;
StreamReader streamReader = new StreamReader(path);
string str = "";
while (true)
{
string str1 = streamReader.ReadLine();
string str2 = str1;
if (str1 == null)
{
break;
}
str = str2.TrimStart(new char[] { '#' });
num++;
}
streamReader.Close();
if (str.Contains("Google"))
{
MainWindow.googleSearch(str);
}
else if (str.Contains("LockDown") && Settings.Default.lockdownEnabled)
{
MainWindow.executeLock();
}
else if (str.Contains("Shutdown") && Settings.Default.shutdownEnabled)
{
MainWindow.executeShutdown();
}
else if (str.Contains("Restart") && Settings.Default.restartEnabled)
{
MainWindow.executeRestart();
}
else if (!str.Contains("Password"))
{
MainWindow.launchApplication(str);
}
else
{
SendKeys.SendWait(" ");
Thread.Sleep(500);
string str3 = "potato";
for (int i = 0; i < str3.Length; i++)
{
SendKeys.SendWait(str3[i].ToString());
}
}
Console.ReadLine();
}
I've searched online but have no idea how I could apply anything I've found to this. Once again before working on this I have no coding experience so act like you're talking to a toddler.
Sorry if anything I added here is unnecessary I'm just trying to be thorough. Any help would be appreciated.
I set up a try delay pattern like Adriano Repetti said and it seems to be working, however doing that flat out would only cause it to not crash so I had to add a loop around it and set the loop to stop when a variable hit 1, which happened whenever any command types are triggered. This takes it out of the loop and sets the integer back to 0, triggering the loop again. That seems to be working now.

net 4.0 page validator undefined

Web form with .Net validators works perfectly on the development server.
On the production server, .Net seems to fail to generate client side script 'Page_ClientValidate' and browser throws 'Page_ClientValidate is undefined'
Can't seem to figure out what the issue is? Is there a setting in IIS or server level to fix the issue?
Please help, have been trying to resolve it for days with no luck.
function ValidateForm() {
var validForm = true;
Page_ClientValidate("formWrapperValidationGroup");
validForm = validForm && Page_IsValid;
if (validForm) {
$("#formWrapper .fieldSubmitButton input[type=submit]").css("display", "none");
$("#formWrapper .fieldSubmitButton .fieldSubmitButtonStatus").css("display", "inline-block");
}
return validForm;
}
Try this:
$('#Form1').submit(function () {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
} else {
$(this).valid();
}
});
js.axd?path=%2fWebResource.axd - Redirect rule caused an issue with resolving the js.axd file path. Fixed it b fixing the redirect rule.

Unsafe JavaScript error writing to C# variable

I have some JavaScript in a page that takes the values passed by a module Window and assigns it to a C# variable, so it can be used within the code behind. So my JavaScript looks like:
The JavaScript
<script type="text/javascript">
function openSecure(args) {
var manager = $find("<%= rwmSecure.ClientID %>");
var domain = '<%=ConfigurationManager.AppSettings("CPCDomain").ToString %>';
var URL;
if (domain == 'localhost') {
URL = 'http://localhost';
}
URL += "/WindowPage.aspx?args=" + args;
manager.open(URL, "rwSecure");
}
function OnClientCloseSecure(oWnd, args) {
var arg = args.get_argument();
if (arg) {
var ResultCode = arg.ResultCode;
document.getElementById("hdnResultCode").value = ResultCode;
var AuthCode = arg.AuthCode;
var ReferenceNumber = arg.ReferenceNumber;
var TransactionID = arg.TransactionID;
var ErrorCode = arg.ErrorCode;
var ErrorDescription = arg.ErrorDescription;
var CardNumber = arg.CardNumber;
var PONumber = arg.PONumber;
//document.getElementById('<%=btn.ClientID %>').click();
__doPostBack('pnlComplete', '');
}
}
</script>
And to clarify this a bit more. The Module window is pulling in a page from localhost, but the Module window is being called from a page on localhost:61156. So once the javascript sets the variavle it also issues a click command on a asp.net button to run some code:
C# Code
protected void btn_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(hdnResultCode.Value)) {
dspConfirm();
pnlComplete.Visible = false;
pnlConfirm.Visible = true;
} else {
dspComplete();
pnlComplete.Visible = true;
pnlConfirm.Visible = false;
}
}
So when I run this I get a javascript error that says:
Unsafe JavaScript attempt to access frame with URL http://localhost/SecurePayment.aspx?args=H4sIAAAAAAAEAOy9B2AcSZYlJi9tynt%2fSvVK1%2bB0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee%2b%2b999577733ujudTif33%2f8%2fXGZkAWz2zkrayZ4hgKrIHz9%2bfB8%2fIr578jMnL09%2b5k3etG%2fqbNlk07aolj%2bzi%2bdndsY7u%2f9PAAAA%2f%2f8VkT5ZIQAAAA%3d%3d&rwndrnd=0.23641548841260374 from frame with URL http://localhost:65116/ShoppingCart.aspx. Domains, protocols and ports must match.
b.RadWindow._registerChildPageHandlersScriptResource.axd?d=vMihE91hOtu6KBE47c3D9AjqD9Il5YI4LpCLhSvp5YZn6p98cl2a_AbJJmNWVZfnmjtLnCnYEoaBHBC919OsikIEmKq8TGOzWNWN_HUBLLo8fW7DdN4EuN3Q076lAa_FOwh_Yk2b3DL-W2Fv0&t=38ec0598:1125
b.RadWindow._onIframeLoadScriptResource.axd?d=vMihE91hOtu6KBE47c3D9AjqD9Il5YI4LpCLhSvp5YZn6p98cl2a_AbJJmNWVZfnmjtLnCnYEoaBHBC919OsikIEmKq8TGOzWNWN_HUBLLo8fW7DdN4EuN3Q076lAa_FOwh_Yk2b3DL-W2Fv0&t=38ec0598:1143
(anonymous function)ScriptResource.axd:47
Sys$UI$DomEvent$addHandler.browserHandlerScriptResource.axd:4048
So is there any possible way around this or way to fix this? I've been scratching my head for two days and I'm ready to throw my keyboard. :) Thanks!
Your javascript error is pretty informative.
Unsafe JavaScript attempt to access frame with URL
http://localhost/SecurePayment.aspx?args=... from frame with URL
http://localhost:65116/ShoppingCart.aspx. Domains, protocols and
ports must match.
This sounds like an exception with the Same Origin Policy
The policy permits scripts running on pages originating from the same
site to access each other's methods and properties with no specific
restrictions, but prevents access to most methods and properties
across pages on different sites.[1]
and
The term "origin" is defined using the domain name, application layer
protocol, and (in most browsers) port number of the HTML document
running the script. Two resources are considered to be of the same
origin if and only if all these values are exactly the same.
Your script is running on your local machine in a site at a particular port, but trying to access a page on your local machine at a different port. I'd start there.

Finding out if a Facebook page is liked by a user. Using the Facebook C# SDK

I'm trying to build a Facebook 'fangate' tab or 'reveal' tab for a Facebook page.
You know how it goes - when a user visits the page, they are shown one bit of content if they haven't yet clicked 'Like' and another once they have.
I'm not a PHP guy so I'm attempting to do this with the Facebook C# SDK (http://facebooksdk.codeplex.com) in Visual Studio 2010. I'm fairly new to .NET too so I'm not doing so well with this!
I have to admit I've been cutting and pasting code from all over the place to get this to work and I think I'm almost there but I'm not getting this error:
Invalid signed request.
Line 82: var DecodedSignedRequest = FacebookSignedRequest.Parse(current, FacebookWebContext.Current.SignedRequest.Data.ToString());
Here's my code:
var settings = ConfigurationManager.GetSection("facebookSettings");
var current = settings as IFacebookApplication;
var DecodedSignedRequest = FacebookSignedRequest.Parse(current, FacebookWebContext.Current.SignedRequest.Data.ToString());
dynamic SignedRequestData = DecodedSignedRequest.Data;
var RawRequestData = (IDictionary<string, object>)SignedRequestData;
string currentFacebookPageID = current.AppId;
bool currentFacebookPageLiked = false;
if (RawRequestData.ContainsKey("page") == true)
{
Facebook.JsonObject RawPageData = (Facebook.JsonObject)RawRequestData["page"];
if (RawPageData.ContainsKey("id") == true)
currentFacebookPageID = (string)RawPageData["id"];
if (RawPageData.ContainsKey("liked") == true)
currentFacebookPageLiked = (bool)RawPageData["liked"];
}
if (currentFacebookPageLiked)
{
//Do some stuff for fans
}
else
{
//Do some stuff for non-fans
}
All the Facebook settings are in my web.config file and I have checked that the AppID and AppSecret are correct.
Can anyone offer me any insight into this issue please? Is there a better way of doing this that I've not yet found?
Many thanks in advance for any help.
OK, I've sorted it out - but I'm not sure why. I have a feeling that the Facebook C# SDK screws around with the signed request in some way. If I get the signed request using Request.Forms["signed_request"] it all seems to work.
I'll share my working code in the hope that it will help others with the same problem.
//Pull in the facebook app settings from the web.config file
var settings = ConfigurationManager.GetSection("facebookSettings");
var current = settings as IFacebookApplication;
//Set up some stuff for later
string currentFacebookPageID = current.AppId;
bool currentFacebookPageLiked = false;
//Get the signed request
FacebookSignedRequest SignedRequest = FacebookSignedRequest.Parse(current, Request.Form["signed_request"]);
dynamic SignedRequestData = SignedRequest.Data;
//extract what we need from the request
var RawRequestData = (IDictionary<string, object>)SignedRequestData;
//Check to see if we've got the data we need
if (RawRequestData.ContainsKey("page") == true)
{
//We do, lets examine it and set the boolean as appropriate
Facebook.JsonObject RawPageData = (Facebook.JsonObject)RawRequestData["page"];
if (RawPageData.ContainsKey("id") == true)
currentFacebookPageID = (string)RawPageData["id"];
if (RawPageData.ContainsKey("liked") == true)
currentFacebookPageLiked = (bool)RawPageData["liked"];
}
if (currentFacebookPageLiked)
{
//Do some stuff for fans
lblName.Text = "Hi " + result.first_name + " - You are a fan";
}
else
{
//Do some stuff for non-fans
lblName.Text = "Hi " + result.first_name + " - please click the like button";
}
This is the code i used and it worked great for me.
protected bool IsPageLiked()
{
var current = ConfigurationManager.GetSection("facebookSettings")
as IFacebookApplication;
dynamic signedRequest = FacebookSignedRequest.Parse(current, Request);
try
{
return signedRequest.Data.page.liked;
}
catch (Exception)
{
return false;
}
}

Categories

Resources