newbie to ASP.NET need help configuring wsaspnet websockets server - c#

I'm new to ASP.NET (did some classic ASPs back in the day, but my how things have changed!) and need to get a proof-of-concept of a browser talking to a server using websockets up-and-running.
I downloaded http://wsaspnet.codeplex.com/
I installed it in a directory called "counter" in my local IIS webroot (counter contains the folders Web, WsTestClient and the file wsaspnet.sln).
I figured out that I needed to copy Global.asax from /counter/Web to / :p
When I access http://localhost/counter/Web/Default.aspx I get the following error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'WebSocks' does not exist in the current context
Source Error:
Line 4: void Application_Start(object sender, EventArgs e)
Line 5: {
Line 6: WebSocks.WebSockServer.Start();
Line 7: }
I realize that this is because the server can't find the code from the file /counter/Web/App_Code/WebSockServer.cs, where the namespace and object are defined.
How do I tell the server where to find this code? I'm guessing that it's a simple matter but I don't know ASP.NET well enough (read: AT ALL) to figure it out :(
Any help would be greatly appreciated!

I finally figured out that everything in the Web folder had to go in the webroot.

Related

XmlException and CryptographicException when running blazor web server app

I receive these two exceptions when I run my blazor web server app:
XmlException: Root element is missing.
CryptographicException: An error occurred while trying to encrypt the provided data. Refer to
the inner exception for more information.
I just created the project and run it... I didn't write any piece of code .
Any help is appreciated because I didn't find any solution till now.
I have found two solutions to fix this issue if someone faced it later.
links to solution:
https://github.com/dotnet/aspnetcore/issues/12830#issuecomment-517907537
https://github.com/dotnet/aspnetcore/issues/12830#issuecomment-606173185

Failed to load resources

I have application which I deploy to Azure and suddenly I catch one error which wasnt in my local machine when I tested application.
Failed to load resource: the server responded with a status of 404 (Not Found)
SO when I tested application in my local machine everything works perfect without any errors, and when I move to test application live on server many option doesnt work, and in console manager I get this kind of error.
Any help, what can be problem here ?
404 is resource not found error. Most probable reasons are your files are in “../“ folder and you are trying to access file in “../..” folder.
I would suggest using URLs like /Folder/subfolder instead of relative URLs like “../parentfolder/subfolder”..
Also, its good to use “~”..
More on paths here:
https://msdn.microsoft.com/en-us/library/ms178116.aspx

Schema specified is not valid. Errors: error 0002: Request failed

I have an EntityFramework project running off MySql that runs great locally as well as on a dedicated server, however I'm trying to move this project to HostGator and I'm receiving the following error:
Schema specified is not valid. Errors:
App_Code.WireWeld.ssdl(2,88) : error 0002: Request failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors:
App_Code.WireWeld.ssdl(2,88) : error 0002: Request failed.
I know the database is correct as I can connect via Navicat and see its contents. I'm pretty sure the connection string is correct, I have the proper username and password.
I'm really stuck on this one and would appreciate any help possible.
If you are using more than one model in your project I advice you to have a look into that topic as it describes possible solutions to the problem.
If you are not using multiple models than this looks like a file permission issue to me.
Perhaps in the hosted environment, the account underwhich your application is running doesn't have access to where the metadata files are located?
You should make sure you have permission (read/write are required). If this is not an option for you than the only go would be to embed the metadata in the assembly directly and use a res:// style connection string.
If you're using SQL server and have 2 projects - one is a class library and the 2nd one uses that class library in main project, then place both dll from class library project to main project refrence.
1-EntityFramework.dll
2-EntityFramework.SqlServer.dll

Mathematica .Net/Link in an Asp.Net application

I am using the Mathematica .Net/Link platform to create a web service to format and calculate math problems. However I am unable to get it working.
I create it using this code:
_Log.IpDebug("Starting the Kernel Link");
if (string.IsNullOrEmpty(_MathLinkArguments))
_InternelKernel = MathLinkFactory.CreateKernelLink();
else
_InternelKernel = MathLinkFactory.CreateKernelLink(_MathLinkArguments);
_Log.IpDebug("Kernel Link Started");
_InternelKernel.WaitAndDiscardAnswer();
The value of _MathLinkArguments is -linkmode launch -linkname \"C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\Math.exe\".
This piece of code is called from the Application_Start method of the global.asax.cs file.
When it gets to the WaitAndDiscardAnswer() call it gives the server error:
Error code: 11. Connected MathLink program has closed the link, but there might still be data underway.
Note: The SampleCode given with the .NET/Link package (both a console app and a WinForms app) works.
Edit:
I copied the console app sample code given with Mathematica into an asp.net page and it gave me the same error the first load and then on subsequent loads it gave me:
Error code: 1. MathLink connection was lost.
Edit2:
I forgot to mention that when I have procmon and task manager open while running my app, I can tell that Math.exe starts but it immediately exits, which makes those error code make complete sense...but doesn't explain why that happened.
To allow the .Net/Link to work in Asp.net (at least in IIS 7.5) you need to enable the property loadUserProfile on the app pool for the web site.
I am not entirely sure why this is the case, but from what I found while trying to debug this, there are some things that are gotten from the user's profile. I know for a fact that the default location of the kernel is, which explains why I couldn't use it with no arguments, and so I can only assume that other things are needed as well and without the profile it couldn't determine that.
But whatever the reason is this is required, it is, or at least it is a fix if you are getting similar problems like this in your own application.
I got the same error in a .Net WinForm application.
mathKernel = new MathKernel();
mathKernel.Compute("<< XYZ`XYZGraphs`");
The error occurred on loading the package straight after instantiating the MathKernel.
To resolve it you can wait a couple of seconds and then instantiating the MathKernel works fine. During this state where there might still be data underway the following conditions are both false:
if (!MathKernel.IsConnected)
{
MathKernel.Connect();
}
if (MathKernel.IsComputing)
{
MathKernel.Abort();
}
Edit:
I've recieved the error again and this time was able to determine the problem.
Using a command line open the MathKernel.exe and view the error message:

Nerd Dinner returns 404s for all sub-pages

I just got a new Windows Server 2003 machine and I've been trying to get Nerd Dinner onto it. The server already has .NET 3.5 SP1, ASP .NET MVC, etc.
When I upload Nerd Dinner via FTP to a subdirectory of the main webpage, I get a 404 when I go to any page in the site except for the root and the home page doesn't event show the map.
For example, when I go to the about page, I get the following IIS log entry:
2009-08-13 17:56:10 128.200.123.118 GET /nerddinner/Home/About - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip>) 404 0 3
I'm extremely puzzled because this is a freshly downloaded and compiled copy of Nerd Dinner from Codeplex.
In case it helps, here's a log entry from the failed attempts to get the JavaScript for the map (note the complete lack of "/nerddinner"):
2009-08-13 18:03:05 128.200.123.118 GET /Scripts/Map.js - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip>) 404 0 3
I have a strong feeling that I should be able to fix this inside the asax.cs file but I can't quite get it to work even after appending "nerddinner/" to the front.
Any ideas for what's happening?
Edit: I uploaded it to the root of the webfolder and the 404s continue.
Edit 2: Thanks for the suggestions. I followed the instructions and now I don't get 404s. However, there are 2 major problems left:
The scripts and content folders don't map correctly. I get 404s on all references to the files inside those folders.
I can't view dinners at all. I get:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
and a line in red that says "<connectionStrings configSource="ConnectionStrings.config" />". Except that ConnectionStrings.config doesn't exist on the server, so it wasn't an important file according to VS, and thus, I have no idea what the error is referring to.
(a quick search of my local hard drive turns up a ConnectionStrings.config file with nothing in it)
Edit 3:
Now I think I'm getting the equivalent of a SQL Server 404 when I go to view dinners...
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Summary To Help Others Running ASP .NET MVC on IIS6, Especially Nerd Dinner:
IIS 6 may throw piles of 404s at you because it doesn't understand that files can have no extensions. To solve that, follow the steps in Phil Haack's blog post.
ASP .NET MVC URL rewriting is not magic. It only rewrites URLs that are piped through code. References to scripts, images, databases, direct links (aka a href tags; not the ones that are dynamically generated) etc. are not remapped based on the directory of your application. For the Nerd Dinner application, go through the pages and add "/nerddinner/" in front of references to these references. Substitute "nerddinner" with the name of your subdirectory.
Take the database and attach it to SQL Server (or SQL Server Express) on your server. Add the Network User to the database with read/write roles.
Fill in the correct connection string for your setup. In my case, I was referring to the server by IP address and using SQL Server 2005 so my connection string is:
<add name="NerdDinnerConnectionString" connectionString="Data Source=128.200.123.118; Initial Catalog=NerdDinner; Integrated Security=SSPI" providerName="System.Data.SqlClient.SqlConnection"/>
Are you running it on IIS6? If you are, you will need to patch the route table to take into account the .ASPX extension, which IIS6 more or less requires.
Phil Haack has a good walkthrough that explains this process. He also explains ways you can do it without the .ASPX extension:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
The scripts and content folders don't
map correctly. I get 404s on all
references to the files inside those
folders.
In ASP.NET MVC files do not map one for one to an URL, like they do in ASP.NET. Instead, a match in the routing table diverts a GET or POST request from the browser to a controller method in one of your controllers. From there, the controller decides (either explicitly or by convention) which View to display.
An error occurred during the
processing of a configuration file
required to service this request.
Please review the specific error
details below and modify your
configuration file appropriately.
ConnectionStrings.config needs to exist on the server, since it is being referenced in web.config. It's an include file, so there doesn't necessarily have to be anything in it. But if it is being referenced, it needs to be included on the server, so just copy it there with your FTP program.

Categories