Request for the permission of type 'System.Net.WebPermission, Failed - vb.net-2010

Edit FIXED!: I feel silly; So after days of investigation and debugging and what not, the answer is/was that the websites were setup the same except for one place I never thought to look; the directories on the live site were inadvertently created using an administrative share instead of the local physical path on the server. After switching the path on the live site, the API works as intended with the rest of the code.
Original Problem:
I have two websites that are hosted on the same server within the same app pool. Website 1 is my testing bed. I have a small class that attempts to call a 3rd part function that basically equates to verifying that a given user exists in the 3rd party's allowable users. If so, it returns true, else returns false. If the return is true, it will redirect to this third party otherwise the user doesn't know anything about the 3rd party.
On my development site, I have the code working 100% without errors, and I get the expected outcome in either case. It's always worked here, never been a problem. However, when I move it to the live site, I get Request for the permission of type 'System.Net.WebPermission, Failed . After extensive googling I am still left puzzled, it's been days. Here's why I am so puzzled:
The server and account that the live and dev site run under are identical.
Their app pools are one in the same
The code is 100% identical.
The web.configs are identical.
Perhaps the single most puzzling part of this is that I use a master-page system in vb.net . The code actually executes in the page_load event of the master-page. The dev site runs without issue, but as soon as you even try to load the page, the code throws the exception. The strangest part is that if I take the code out of the master-page page_load and create a new blank page with nothing but this call and the page_load code that calls it, it works.
I've examined this master-page so thoroughly, and I cannot believe it works on dev but not live, and I was completely taken aback yesterday when my experiment with a new page and the same code worked on the live site.
What I've tried so far in trying to resolve this:
Load user profile = true in the AppPool
Did a direct compare of the code to ensure it is 1:1
Verified permission for the account this runs under
Rebooted web servers
Set Full trust via the web/config
I'm at a loss. Below is the code - it's so simple and yet this problem persists. I cannot figure out why it works on the live site just not with specific page I need it to. Here's the respective code:
Sub page_load()
If Not Page.IsPostBack Then
Dim SFUser As New StorefrontUser
'Response.Write(SFUser.GetadminticketValue)
If SFUser.isActiveStorefrontUser = 1 Then
LBCELink.Style.Add("visibility", "visible")
Else
LBCELink.Style.Add("visibility", "hidden")
End If
End If
End Sub
And here is the class/function it calls:
Public Class StorefrontUser
Dim storefront As New SXI.StorefrontAPIHelper("http://subdomain.blah.com/3rdpartyAPI.asmx")
Function isActiveStorefrontUser() As String
If GetAdminTicket() <> "UNAUTHORIZED ACCESS" Then
Return storefront.GetValue("UserProperty", "IsActive", storefront.FindUserID(theID))
Else
Return "1"
End If
End Function
Function GetadminticketValue() As String
Return GetAdminTicket()
End Function
Public Function GetAdminTicket() As String
Dim ScratchTicket As String = String.Empty
Try
ScratchTicket = storefront.ObtainUserTicket("user", "password", "Identity")
Catch ex As Exception
HttpContext.Current.Response.Write(ex.ToString)
ScratchTicket = String.Empty
End Try
Return ScratchTicket
End Function
End Class
Works fine on Live site if it's not part of the Master page which it needs to be, works fine on the dev site anywhere. Totally stumped. Apologies if my formatting is poor or if my question lacks clarity; First time caller, long time listener.
One last important piece of information is that a reference to the 3rd party's dll is required to make use of their API - which seems like a valid point of contention except that it works on the blank page I created, just not with this master page which is identical to the dev site's master-page.
Thanks in advance for any light you can shed.

Related

How can I identify where Yii application execution is ending?

Prerequisites: Running on Ubuntu. Using Apache. Yii version is printing 1.1.2.
My question:
I'm helping a friend out with a web app where his application developer abruptly quit. The problem is, I'm somewhat green with PHP and COMPLETELY green with Yii. I'm having a difficult time setting up a test server using the existing code. What's happening is the index.php code calls a CWebApplication-derived class, but the run() method never returns, and all I get is a blank page (this obviously doesn't happen in production). I'm trying to understand how to identify what's happening, and where the execution is just dying.
First, let me say that I ran http:///yii/requirements/index.php, and the requirements checker claimed I had the minimum requirements to run.
Second, my index.php looks like this:
ini_set('display_errors',1);
// change the following paths if necessary
$yii=dirname(__FILE__).'/yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
$gapi = dirname(__FILE__) . '/protected/vendors/Google/autoload.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($gapi);
require_once($yii);
/*
* Manage URL Uppercase or lowercase
*/
$manage_url_path = dirname(__FILE__) . '/protected/components/ManageUrl.php';
require_once( $manage_url_path );
$create_web_application = new ManageUrl($config);
$create_web_application->run();
When $create_web_application->run() executes, it never returns (printing after it prints nothing), and I get just a blank page.
This class (ManageUrl) overrides createController, but so far it feels like execution never makes it to this function. Placing any print() statements in there shows nothing. $Yii::log() also shows nothing. There's nothing in the application.log under /runtime. Apache's error logs are showing nothing too. It's as if code execution is just going into a black hole.
One final thing to note: I've got mod_rewrite enabled on the server. I followed this outdated howto on DigitalOcean to get things started (https://www.digitalocean.com/community/tutorials/how-to-install-and-setup-yii-php-framework-on-ubuntu-12-04).
Can you advise me on how to figure out what's going on with this application and why I just get a blank page? I need to figure out where the code execution is going and subsequently dying.

ApplePayJS InvalidAccessError

Trying to integrate ApplePayJS into my website and getting this annoying message::
InvalidAccessError Code 15
"The object does not support the operation or argument"
Everything seems to have been going well and now nothing works.
If you get this error, in my experience Safari is now dead to ApplePayJS and you must start by force quitting and reopening it again.
Turns out the reason for me what that the ApplePay API completely craps out if you pass a string instead of an object into the completeMerchantValidation.
If what you return from your server is not JSON object, but a string instead then you can do this:
session.completeMerchantValidation(JSON.parse(merchantSession));
Or better still - fix your server to return a JSON object instead of a string.
Update 4 years later:
I just saw this again today for a real customer as opposed to during my own testing. In this instance the order had succeeded and the customer thought it had failed so attempted to go through the process again.
Oddly it was on this call with the same error "The object does not support the operation or argument."
applePayTokenize.session.completePayment(ApplePaySession.STATUS_SUCCESS);
Since the payment succeeded I've changed my logic to just ignore the exception (for STATUS_SUCCESS only) and proceed to the final page. I don't even know if the ApplePay sheet was still open but even if it was at least when it cancels it will be on the receipt page.
I have also had this issue but with a different reason
Your domain name in the session needs to equal the domain name of your browser. you set the domain name in the backend during in the initiativeContext
https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/requesting_an_apple_pay_payment_session

SQL Network Interfaces, error: 26 only on solution rebuild

I have a site built using MVC4 which is getting content out of a database and it all works fine.
If I then rebuild the solution and try to refresh the page to check my changes, I will always get the SQL Network Interfaces, error: 26 saying that I cannot connect to the server.
However, if I then browse to my homepage and then back to the page I was looking at it will work fine.
Does anyone know what could cause this problem as it is really annoying
EDIT
Further to this I have found it is when the AuthorizationContext filterContext is being loaded after the rebuild that it cannot connect to the db
EDIT 2
As with neil below I have found that I only get the problem if I try to access a page that has had a role assigned to it
I'm seeing the exact same problem and can trace it to the .ASPXAUTH session cookie in the browser. Delete that cookie and the database error goes away until the next rebuild.
The error occurs regularly if you are authenticated and then rebuild the project and try to browse any page that either:
Requires authentication
Makes a call to the User object (e.g. #if (User.IsInRole("Administrators")))
If you have the AuthorizeAttribute filter set in App_Start/FilterConfig.cs you'll get this on every page.
This seems to be new behavior following the most recent Patch Tuesday updates. Previously, I was seeing weird behavior where I would remain logged in but I would loose my roll membership. After the most recent patches, it seems Simple Membership chokes when it gets a bad .ASPXAUTH cookie (invalid because of the rebuild).
I've got the correct connection string in InitializeSimpleMembershipAttribute.cs but it's like Simple Membership is defaulting to something else in this one instance.
Note that I've moved the Simple Membership databases from the original (localDb) to a full-fledged (local) SQL Server instance. Don't know why that would matter, and it works fine in all other cases.
Update:
I've also tried making the connection string name the same as the EF context name (e.g. "ProjectContext") on the theory that it is defaulting to the standard convention, but that made no difference. I am explicitly identifying the connection string name in all my context class constructors (using the : base("connectionString") syntax) and Simple Membership is able to find the right connection string all other times.
Update 2:
The problem only occurs after rebuild when accessing a page protected by role. A simple [Authorize] won't trigger it. You need something like [Authorize(Role="Admin")]. I've replicated this on a new MVC 4 project with no other modifications, using the default (localDb) database. Clear the cookie and that same user can access the protected content w/o any problems. I believe this is a core .NET or MVC bug and needs to be reported as such.
This happened to me while rebuilding the application when I was logged in the browser.
Deleting cookies fixed the problem for me.
When using SimpleMembership, this bug occurs with any use of Roles-not just in the controller, but also when I use:
if(Roles.IsUserInRole(rolename){...
I am late to the game with this answer, but I added [InitializeSimpleMembership] to my home controller and I think that fixed it.

Object already exists exception in RSACryptoServiceProvider

First let me start by saying I'm sorry if I posted this question in the wrong place. I saw the entry at Object already exists in RSACryptoServiceProvider. I tried the solutions offered there. But, they did not solve my issue. Also, I didn't see an option to re-ask the question.
I have almost the same issue. I have a class that uses RSACryptoServiceProvider that runs in two projects on the same machine and under the same account. Both projects live in the same solution and share the same encryption code. One project, the server, is a Windows service and the other, the client, is a Windows application. They use the RSACryptoServiceProvider to talk to each other over a named pipe using asymmetric encryption. I started out by just having the server run in another Windows form within the same application as the client. Everything ran fine. Then, I moved the server to a Windows service.
The Windows service starts up fine. It seems to be able to create it's instance of the RSACryptoServiceProvider fine. But, when the client, which runs in the Windows application, starts up it gets a runtime error when it tries to create it. Here is the code that runs in both projects.
rule = New CryptoKeyAccessRule("everyone", CryptoKeyRights.FullControl, AccessControlType.Allow)
csp = New CspParameters
csp.KeyContainerName = _KeyContainerName
csp.Flags = CspProviderFlags.UseMachineKeyStore
csp.CryptoKeySecurity = New CryptoKeySecurity()
csp.CryptoKeySecurity.SetAccessRule(rule)
//Object already exists exception happens here
rsa = New RSACryptoServiceProvider(_KeySize, csp)
As you can see, I have the code that sets the access rule as mentioned in the other post on this subject. Unfortunately, this did not solve my issue. Is there anything else that needs to change?

Another doGet() issue with Google Apps Script - "Unknown macro doGet" error

I'am obviously new to Google Apps Script, nevertheless I have some experience in coding in C, PHP and Java. Since we would like to create a small CRM in our company with Google Apps Script, we need to create an application with a form available on Google Sites. I've been searching an answer for this problem a long time, I haven't unfortunately found any answer. I have a code like this:
var klienci_id = new Array(100);
var klienci_nazwa = new Array(100);
var klienci_adres = new Array(100);
var klienci_osoba = new Array(100);
var klienci_telefon = new Array(100);
var klienci_email = new Array(100);
function doGet(e) {
var app = UiApp.createApplication();
// hello world label
var helloworldLabel = app.createLabel("I love Apps Script!").setStyleAttribute("fontSize","16px");
// add the label to the app container
app.add(helloworldLabel);
return app;
}
function main() {
var klienci = SpreadsheetApp.openById("0ArsOaWajjzv9dEdGTUZCWFc1NnFva05uWkxETVF6Q0E");
var kuchnia_polska = klienci.getSheetByName("Kuchnia polska");
var dane = kuchnia_polska.getRange("D7:F22");
doGet();
}
And everytime I try to publish it and enter the given link I get the error "Unknown macro doGet". I know this is a common problem when somebody doesn't use doGet() function but I do - and it still doesn't work. I also believe that Google should create a thorought documentation on Google Apps Script, which would work the way the Unix manual does, since I just cannot get through all these strange pages of goddamn help :) It's neither a Windows help, nor a good manual ;)
Regards,
Kamil
I have a suspicion that you made a "version" once, published the app, went to the "real" link and not the "development" link, and then added the doGet() function. When you make a version, it freezes the code at that time. The version that the app is published at is the version of the code that will run at the "real" link (what you give users), which allows you to keep editing the code without disturbing existing users of your app. There is a special "development" link given to you in the publish dialog that always refers to the most recent version of the code, but which will only work for you and no one else.
I'm affraid there is a little misunderstanding on your side concerning the use of the 'doGet()' function. When you want to run an application as a webapp, the doc says indeed that it must contain a doGet function but what it doesn't say explicitely is that this function is supposed to be the starting point of the whole app, ie the function that the url will call in the first place. So it doesn't make much sense to have the doGet function called from a so called "main" function since the "main" function is not the main function...
I cannot imagine right now a situation where some function calls the doGet function since every function in the script is called initially (directly or indirectly) from this doGet function.... in fact the 'end' of any other function in the script 'returns' to the doGet initial function. Well this is maybe not absolutely true in every case but it gives you the general idea about how it works.
I'm hoping this is clear enough and, to return to your code snippet, if you remove the doGet(e) call, it will ideed show a nice "I love Apps Script!" but it will never do anything else, certainly not see the "main" function.
I've copied your code here https://script.google.com/macros/d/MJ80AK8t7kbgDcC-NaLPYvH797_hv7HHb/edit?template=app&folder=0AKGkLMU9sHmLUk9PVA
and when deployed as a web app appears to work https://script.google.com/macros/s/AKfycbxOiaukLt7P4pIm7bms7aU16uEo6FuZ-MNOh0tSqUwr/dev
Only thing I can think of is there is something else in your code not copied into the snippet that is throwing the exception.
[Just before the GUI Builder was published I came up with Creating a framework for custom form interfaces using Google Apps Script which might help you with your project]
Thank you both for help. Serge, yes, it's really not obvious what the structure of Google Apps Scripts should be. They are based on JavaScript, however, due to lack of HTML in the code they have completely different flow - so naturally, there has to be a main function which is executed first. And of course in every programming environment it has to have a different name to make it more distinguishable ;-)
I created a new copy of my application, not changing the code completely - deployed it and it works beautifuly. Since I haven't changed anything in access options, it's quite strange that two applications with the same code and the same options don't give the same result. I think it may be a kind of the environment flaw, maybe someone from Google should look at this :)
Here's the link to the script, I've set access to "Anyone with the link".
https://script.google.com/a/macros/foodbroker.pl/s/AKfycbwk2IM-rIYLhQl6HOlbppwGOnw4Ik_kH7ixbaSNVxIE-QR7cq8/exec