Executing a .bat file from ASP.NET / VB.NET on the server - asp.net

I'm trying to execute a batch file, for testing purposes it's called -> test.bat
the location of the file is in a Folder named scripts.
Following have I tried:
System.Diagnostics.Process.Start(Server.MapPath("Scripts/test.bat"))
System.Diagnostics.Process.Start("C://......Scripts/test.bat"))
Dim batDir As String = Server.MapPath("C://...../Scripts/") 'And with String format()
proc = New Process()
proc.StartInfo.WorkingDirectory = batDir
proc.StartInfo.FileName = "test.bat"
proc.StartInfo.CreateNoWindow = False 'Don't know what this is, copied it from somewhere.
proc.Start()
proc.WaitForExit()
And I don't get any exception.
Edit 1:
My test.bat should create a folder on the Desktop (Testing purposes).
Edit 2: I'm getting this warning in the Event Log
Event code: 3001
Event message: Request was cancelled.
Event time: 21.07.2020 14:17:09
Event time (UTC): 21.07.2020 12:17:09
Event ID: 4dbd86698e044d2092a89ed01d24f418
Event sequence: 3809
Event occurrence: 4
Event detail code: 0
Application information:
Application domain: xxx
Trust level: Full
Application Virtual Path: xxx
Application Path: C:\xxx
Machine name: xxx
Process information:
Process ID: 8388
Process name: w3wp.exe
Account name: IIS APPPOOL\DefaultAppPool
Exception information:
Exception type: HttpException
Exception message: Request time exceeded.
Request information:
Request URL: http://xxx\mySite.aspx
Request path: \mySite.aspx
User host address: xxx
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\DefaultAppPool
Thread information:
Thread ID: 138
Thread account name: IIS APPPOOL\DefaultAppPool
Is impersonating: False
Stack trace:
Custom event details:
Could it be a Authentication problem?

Try to add the execution permission to the IIS = "APPPOOL\DefaultAppPool" User and now your folder should be able to be created successfully.

Related

Business Object Repository initialized on wrong domain

We are using Intershop 7.10.10.1 and there is strange problem we are facing regarding initialization of PostpaidPriceBORepositoryExtensionImpl (AbstractDomainRepositoryBOExtension). There are 4 application servers, and now and then method "getDomain()" from "AbstractDomainRepositoryBOExtension" just on one application server (and that problem occurs only on that app server until it's restarted) returns different domain (from another channel).
We ere initializing that repository from custom basket PLI extension (BasketPliBOA1CustomExtensionImpl) by:
final BusinessObjectRepositoryContext context = getContext().getVariable(BusinessObjectRepositoryContext.CURRENT);
postpaidPriceBORepository = context.getRepository(PostpaidPriceBORepositoryExtensionFactory.EXTENSION_ID);
This is log message with wrong domain:
[2019-08-22 16:55:19.082 CEST+0200] DEBUG lvpislive1.vipnet.hr ES1 appserver0 [A1-Shop-Site] hr.a1.component.postpaid.price.capi.PostpaidPriceBORepository [] [Storefront] [U4orJF6aQTkzJQPE-Zecvq2QBdF3vzutXXB9fwIB] [3CZ1Al1erNa3mvMK-0-00] "3CZ1Al1erNa3mvMK-0-00" Calling getPostpaidPriceBO with following parameters: productID - BSsK85q6.1IAAAFpaSPwkTzN, tariffID - Ayl_AAEB068AAAFm2D5_ByXz, contractType - A, contractBinding - 24, domainID - VcwK_Slyn1kAAAFl9O1ujvEU.
And here with corect one:
[2019-08-22 16:55:19.145 CEST+0200] DEBUG lvpislive1.vipnet.hr ES1 appserver0 [A1-Shop-Site] hr.a1.component.postpaid.price.capi.PostpaidPriceBORepository [] [Storefront] [U4orJF6aQTkzJQPE-Zecvq2QBdF3vzutXXB9fwIB] [3CZ1Al1erNa3mvMK-0-00] "3CZ1Al1erNa3mvMK-0-00" Calling getPostpaidPriceBO with following parameters: productID - BSsK85q6.1IAAAFpaSPwkTzN, tariffID - Ayl_AAEB068AAAFm2D5_ByXz, contractType - A, contractBinding - 24, domainID - aPIK_Sly.tEAAAFlWeJujvEU.
As you can see on first log message is domain ID from A1-Tomato-Site and strange is that request and log file is for A1-Shop-Site (different channel). Also you can see in log messages that both of them are from same session, even from same request (request ID is 3CZ1Al1erNa3mvMK-0-00).
This is code snippet from PostpaidPriceBORepositoryImpl:
LOGGER.debug("Calling getPostpaidPriceBO with following parameters: productID - {}, tariffID - {}, contractType - {}, contractBinding - {}, domainID - {}.",
productID, tariffID, contractType, contractBinding, getDomain().getDomainID());
final A1PostpaidPricePO postpaidPricePO = postpaidPricePOFactory
.getObjectByAlternateKey(new A1PostpaidPricePOAlternateKey(productID, tariffID, contractType.getName(), contractBinding, getDomain().getDomainID()));
Do you know what could be reason for that? Just to repeat what is strange, this is happening on only one application server (after every restart on different one, so that isn't consistent either). There is possibility if we have luck that after restart this doesn't happen on any of app servers, but after next restart problem occurs on one app server (one time we had problem on two of them from 4).
Thank you for your help.

Deploying Watson Chat on IIS

So I've created a simple ASP .NET site, where you can send a message to the Watson service and receive the response.
It works locally when I run the application from VS2017, but now I've deployed it to my 2012 R2 Server and it doesn't work.
The application runs, but I'm not able to receive any answer from the Watson service.
What am I missing in the IIS?
This is the SDK, I've been using.
https://github.com/watson-developer-cloud/dotnet-standard-sdk
Here is the only error I can find in the eventvwr.
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 25-04-2019 15:51:35
Event time (UTC): 25-04-2019 13:51:35
Event ID: 8eb66320f2fa412ea0a2cf3f61d5f3b2
Event sequence: 19
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/6/ROOT-6-132006738849963250
Trust level: Full
Application Virtual Path: /
Application Path: xxx
Machine name: OSI4908
Process information:
Process ID: 6844
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: HttpException
Exception message: The remote host closed the connection. The error code is 0x80070057.
at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
at System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()
at System.Web.HttpResponse.Flush(Boolean finalFlush, Boolean async)
at System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size)
at Microsoft.Owin.Host.SystemWeb.CallStreams.OutputStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.AspNet.SignalR.Owin.ServerResponse.Write(ArraySegment`1 data)
at Microsoft.AspNet.SignalR.Hosting.ResponseExtensions.End(IResponse response, String data)
at Microsoft.Owin.Mapping.MapMiddleware.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Azure SQL Database is fully occupied without requests

I am using an Azure Web App (own ASP.NET Project) combined with an Azure SQL database.
My web application is requesting the database on each request to check the userlevel for example.
The workload on the Azure charts are totally normal but sometimes there are some strange workloads after special events. For example I worked on the ASP.NET Project yesterday at 9PM on my local machine without publishing or opening the Server Explorers. I also did not update the firewall IP in Azure for accessing the database from my local machine.
After a hour of work I noticed that the website was sending back a 502 Error after loading for 1.5 minutes.
I took a look on the charts and noticed that the database was occupied by requests since I started programming on the local machine.
Trying to republish, restart the server and changing the database pricing tier did not help.
The Azure Web App Chart:
The Azure SQL Database Chart:
I have no idea why this happens because it is not the first time and the downtime is not that short.
--- EDIT: ---
As #DanRediske-MSFT mentioned below I tracked the SQL queries in the Management Studio and saw that there is one statement which is using a lot of resources (is executing extremely long):
The SQL big resource statement is really long because it is generated by the Entity Framework:
SELECT
[Project1].[AccessFailedCount] AS [AccessFailedCount],
[Project1].[Id] AS [Id],
[Project1].[UserDomain] AS [UserDomain],
[Project1].[Email] AS [Email],
[Project1].[EmailConfirmed] AS [EmailConfirmed],
[Project1].[PasswordHash] AS [PasswordHash],
[Project1].[SecurityStamp] AS [SecurityStamp],
[Project1].[UserName] AS [UserName],
[Project1].[AccountDetail_Id] AS [AccountDetail_Id],
[Project1].[AccountSetting_Id] AS [AccountSetting_Id],
[Project1].[BusinessDetail_Id] AS [BusinessDetail_Id],
[Project1].[LeadCollection_Id] AS [LeadCollection_Id],
[Project1].[PaymentDetail_Id] AS [PaymentDetail_Id],
[Project1].[UserDetail_Id] AS [UserDetail_Id],
[Project1].[C2] AS [C1],
[Project1].[Id1] AS [Id1],
[Project1].[OrderDate] AS [OrderDate],
[Project1].[OrderNumber] AS [OrderNumber],
[Project1].[HasBeenHandled] AS [HasBeenHandled],
[Project1].[OrderId] AS [OrderId],
[Project1].[PaypalSubscriptionID] AS [PaypalSubscriptionID],
[Project1].[IsActive] AS [IsActive],
[Project1].[Product_ProductID] AS [Product_ProductID],
[Project1].[User_Id] AS [User_Id],
[Project1].[C1] AS [C2],
[Project1].[PaymentID] AS [PaymentID],
[Project1].[PaymentDate] AS [PaymentDate],
[Project1].[Amount] AS [Amount],
[Project1].[HasBeenHandled1] AS [HasBeenHandled1],
[Project1].[TransactionID] AS [TransactionID],
[Project1].[Order_ID] AS [Order_ID]
FROM ( SELECT
[Extent1].[Id] AS [Id],
[Extent1].[UserDomain] AS [UserDomain],
[Extent1].[Email] AS [Email],
[Extent1].[EmailConfirmed] AS [EmailConfirmed],
[Extent1].[PasswordHash] AS [PasswordHash],
[Extent1].[SecurityStamp] AS [SecurityStamp],
[Extent1].[AccessFailedCount] AS [AccessFailedCount],
[Extent1].[UserName] AS [UserName],
[Extent1].[AccountDetail_Id] AS [AccountDetail_Id],
[Extent1].[AccountSetting_Id] AS [AccountSetting_Id],
[Extent1].[BusinessDetail_Id] AS [BusinessDetail_Id],
[Extent1].[LeadCollection_Id] AS [LeadCollection_Id],
[Extent1].[PaymentDetail_Id] AS [PaymentDetail_Id],
[Extent1].[UserDetail_Id] AS [UserDetail_Id],
[Join2].[ID] AS [Id1],
[Join2].[OrderDate] AS [OrderDate],
[Join2].[OrderNumber] AS [OrderNumber],
[Join2].[HasBeenHandled1] AS [HasBeenHandled],
[Join2].[Product_ProductID] AS [Product_ProductID],
[Join2].[User_Id] AS [User_Id],
[Join2].[OrderId] AS [OrderId],
[Join2].[PaypalSubscriptionID] AS [PaypalSubscriptionID],
[Join2].[IsActive] AS [IsActive],
[Join2].[PaymentID] AS [PaymentID],
[Join2].[PaymentDate] AS [PaymentDate],
[Join2].[Amount] AS [Amount],
[Join2].[HasBeenHandled2] AS [HasBeenHandled1],
[Join2].[TransactionID] AS [TransactionID],
[Join2].[Order_ID] AS [Order_ID],
CASE WHEN ([Join2].[ID] IS NULL) THEN CAST(NULL AS int) WHEN ([Join2].[PaymentID] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1],
CASE WHEN ([Join2].[ID] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C2]
FROM [dbo].[AspNetUsers] AS [Extent1]
LEFT OUTER JOIN (SELECT [Extent2].[ID] AS [ID], [Extent2].[OrderDate] AS [OrderDate], [Extent2].[OrderNumber] AS [OrderNumber], [Extent2].[HasBeenHandled] AS [HasBeenHandled1], [Extent2].[Product_ProductID] AS [Product_ProductID], [Extent2].[User_Id] AS [User_Id], [Extent3].[OrderId] AS [OrderId], [Extent3].[PaypalSubscriptionID] AS [PaypalSubscriptionID], [Extent3].[IsActive] AS [IsActive], [Extent4].[PaymentID] AS [PaymentID], [Extent4].[PaymentDate] AS [PaymentDate], [Extent4].[Amount] AS [Amount], [Extent4].[HasBeenHandled] AS [HasBeenHandled2], [Extent4].[TransactionID] AS [TransactionID], [Extent4].[Order_ID] AS [Order_ID]
FROM [dbo]
It looks like the statement would not be complete but that's all I see in the .sqlplan file StatementText Attribute. So here it would be the complete file for that statement: http://alexpower.de/snippet.sqlplan
For me it now would be intresting to know which EF code is generating that statement. Is this possible to get that information?
--- EDIT: ---
Found some interesting Events in the Event Viewer on domainname.scm.azurewebsites.net/Support but don't know what to do with it:
Info:
.NET Runtime version 4.0.30319.0 - Loading profiler failed. Failed
trying to receive from out of process a request to attach a profiler.
HRESULT: 0x8007006d. Process ID (decimal): 4716. Message ID: [0x250d].
Warning:
Worker Process requested recycle due to 'Percent Slow Requests' limit.
Error:
Event code: 3005 Event message: An unhandled exception has occurred.
Event time: 3/22/2017 9:47:27 PM Event time (UTC): 3/22/2017 8:47:27
PM Event ID: 919f06b7f5e647beb75be7c8400d107f Event sequence: 8 Event
occurrence: 1 Event detail code: 0
Application information: Application domain:
/LM/W3SVC/712043775/ROOT-1-131346876896158300 Trust level: Full
Application Virtual Path: / Application Path: D:\Program Files
(x86)\SiteExtensions\Kudu\61.60316.2745\ Machine name: RD00155D56FC01
Process information: Process ID: 5064 Process name: w3wp.exe Account
name: IIS APPPOOL\onlineplaybook
Exception information: Exception type: HttpException Exception
message: Server cannot append header after HTTP headers have been
sent. at System.Web.HttpHeaderCollection.SetHeader(String name, String
value, Boolean replace) at System.Web.HttpHeaderCollection.Add(String
name, String value) at
Kudu.Services.Web.Tracing.TraceModule.OnBeginRequest(Object sender,
EventArgs e) at
System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
Request information: Request URL:
https://onlineplaybook.scm.azurewebsites.net:443/msdeploy.axd?site=onlineplaybook
Request path: /msdeploy.axd User host address: 79.248.163.180 User:
Is authenticated: False Authentication Type: Thread account name: IIS
APPPOOL\onlineplaybook
Thread information: Thread ID: 20 Thread account name: IIS
APPPOOL\onlineplaybook Is impersonating: False Stack trace: at
System.Web.HttpHeaderCollection.SetHeader(String name, String value,
Boolean replace) at System.Web.HttpHeaderCollection.Add(String name,
String value) at
Kudu.Services.Web.Tracing.TraceModule.OnBeginRequest(Object sender,
EventArgs e) at
System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
Custom event details:

"Access violation reading location" in IISExpress 10 (in webengine4.dll) with Selenium IEDriver 12.6

My configuration as follows. XUnit runner (1.9.2) fires tests generated using SpecFlow. IISExpress 10 starts in singleton like this:
_iisProcess = new Process {
StartInfo = {
FileName = Path.Combine(programFiles, #"IIS Express\iisexpress.exe")
}
};
var applicationPath = GetApplicationPath();
_iisProcess.StartInfo.Arguments = string.Format(
"/path:{0} /port:{1} /systray:false /trace:e",
applicationPath,
IisPort); // so far 9090
_iisProcess.Start();
Selenium IEDriverServer.exe (2.46) configured as this:
_driver = new InternetExplorerDriver(
new InternetExplorerOptions(){EnsureCleanSession = true});
The machine configured as per this guide. IEDriverServer.exe listens 17923 port.
At some points in tests IISExpress fails with "Access violation" (c0000005) error. The actual fail system test varies but looks like it happens when there is some active UI interaction. There is SignalR, dynamic content and other. The Problem signature:
Problem Event Name: APPCRASH
Application Name: iisexpress.exe
Application Version: 10.0.10046.0
Application Timestamp: 55121079
Fault Module Name: webengine4.dll
Fault Module Version: 4.6.57.0
Fault Module Timestamp: 551b8b21
Exception Code: c0000005
Exception Offset: 00066ccf
OS Version: 6.3.9600.2.0.0.256.48
Locale ID: 1049
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: a10f
Additional Information 4: a10ff7d2bb2516fdc753f9c34fc3b069
Sometimes it fails at code like this with "OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds" at DefaultWait.Until
IWait<IWebDriver> wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30.00));
try
{
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
}
catch (InvalidOperationException ex) // js error { /*...*/ }
IISExpress log also does not help. It writes some last requests only and terminates:
Request started: "POST" http://localhost:9090/signalr/abort?transport=webSockets...
Request ended: http://localhost:9090/signalr/connect?transport=webSockets... with HTTP status 101.0
Request ended: http://localhost:9090/signalr/abort?transport=webSockets&clientProtocol=1.4.... with HTTP status 200.0
WriteCompletedInline
Action = 00000002
Action = 00000000
Request ended: http://localhost:9090/signalr/connect?transport=webSockets.... with HTTP status 101.0
Request ended: http://localhost:9090/BotDetectCaptcha.ashx?get=image&c=SampleCaptcha&t=44c45e60afac46809bfce16e123b54a2 with HTTP status 200.0
It does not help if the tests run under Administrator. The same when R# test runner fires the tests.
Any your thoughts, help would be much appreciated. Thanks!
In case it would be helpful someone it helped me to solve the problem by the reinstallation of IIS Express. IIS Express 8.0 MSI file could be found at here.

ASP.NET project calling a VB6 Ddll, error REGDB_E_READREGDB

I have a project in aspx with vb.net and this app calls a COM + DLL, and this DLL reads a registry key, in my VB6 app uses this DLL correctly, but adding this DLL's references on my .NET project, i get this error below:
Somebody help me with this error, pls...
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 27/8/2014 11:25:13
Event time (UTC): 27/8/2014 14:25:13
Event ID: c94e2752e983457cb159dc7d9e5f75a1
Event sequence: 7
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/Constito-1-130536231061632161
Trust level: Full
Application Virtual Path: /Constito
Application Path: C:\Constito\
Machine name: SERVER-Constito
Process information:
Process ID: 7116
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: Exception
Exception message:
Unable to cast COM object of type 'System.__ComObject' to interface type 'U_Master.Obj'.
This operation failed because the QueryInterface
call on the COM component for the interface
with IID '{BE0634D8-325E-4A3E-9426-44D52F118BF9}'
failed due to the following error:
Could not read key from registry
(Exception from HRESULT: 0x80040150 (REGDB_E_READREGDB)).
at Constito.Master.Post_DadosVB6(Object obj, String acao, String xmlArg, String p_cd_usuario) in C:\Constito\Master.vb:line 102
at Constito.Principal.Page_Load(Object sender, EventArgs e) in C:\Constito\Principal.aspx.vb:line 30
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint)
Try setting the Application Pool user to an account with local admin privileges on the Web Server.
It looks like a registry permissions issue.
If thats not it ensure that the GUID (BE0634D8-325E-4A3E-9426-44D52F118BF9) exists in the HKEY_CLASSES_ROOT hive.

Resources