EDIT2
Looks like I can't read properly, disregard this post, I will try to make a WCF service instead.
Thank you
EDIT:
Ok it seems I should start learning MVC instead. I tried getting into it before when I could't get this to work but maybe I didn't try hard enough because I already completed my web services and didn't feel like starting over before I knew if the problem was trivial.
For those who are interested:
What I am actually trying to accomplish is to create a database with a dozen different highscore tables which I will be able to retrieve from my Android app as JSON. So far I have an XML database and a webmethod for asking if a score is in the top 50 on a specific highscore table. One for submitting your score, and one for retrieving the entire highscore to show in the app. I also have a simple interface for adding, removing etc from the database.
Updated question: Will I be able to reuse some of my code if I create an MVC project and how do I put said project on the server? can it be done with an FTP client or do I need to use Web Deploy, IIS or web matrix or some other software? and what are the requirements of the server?
Thank you so much for the help :)
----------Original Post--------------
Recently I have been trying to learn how to create a web service in Microsoft Visual Web Developer (2010 express on win7 64bit) in a web application. I have a few very simple JSON web methods and when I run the project locally from Visual Web Developer it works like a charm, they return the correct values etc.
But when I transfer the project to my windows server running .NET 4.0 (which is the same as my target framework in this project) I can't access the web service anymore, the .aspx web pages work great but the .asmx web service shows the following error:
(I can only post two hyperlinks yet so I removed this image)
That line 1 is the only line in the .asmx file btw. I have tried putting the Namespace.Classname there instead but the error remains. (Test.DBWebService instead of just DBWebService)
I haven't changed anything in the code, this exact code does work on my computer. I have tried things that helped others with similar issues, like the build options:
Before running startup page: Build Web Site
Target Framework: .NET 4.0
Build Web Site as part of a framework Checked
which I assume should be configured like that.
My web.config looks like this:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
<appSettings>
</appSettings>
<system.serviceModel>
<bindings/>
<client/>
</system.serviceModel>
</configuration>
This is the .cs file for the web service and an example method which works locally but can't be accessed on the server.
http://i.stack.imgur.com/4T6pq.png
What could possible create this problem? Am I missing something vital here because I am not very experienced. I have tried for days to get this done and even asked my web hosting company but they said they don't help with programming related issues.
If you are just now learning web services, then you should stop right now. You've made a major mistake.
You are using "ASMX Web Services", a technology which is all but obsolete. No new development should be done using ASMX unless there is no other choice.
Another mistake you are making is in using the web site "project". I strongly recommend you not use those for anything other than simple sites, and you might want to avoid them for that purpose in any case. Among other things, they have this precise issue with not building what you think they should build when you think they should build it.
Use a web application project instead, using "Add New Project" instead of "Add New Web Site".
Most probable causes of your issue are:
- wrong configuration of the site (application) within the IIS. My guess is that you are deploying onto an application but for some reason the application is not correctly created and the ASP.NET is unable to initialize the /bin folder where the binaries should exist
- wrong configuration of the IIS/ASP.NET. Find another machine with similar configuration and check your site there. If it works correctly, you could go back and try to find/resolve issues with your local ASP.NET configuration.
Related
I just created basic Web API using Visual Studio 2022 > create new project > selected the C# ASP.NET Core Web API template. And it created the weatherforecast Web API and everything worked fine on my local system.
But when I deploy this to Azure Appservice, I get a 500 error. Any idea what's going on?
Usually, when we use Swagger, we will encounter a 404 error when publishing to Azure App Service. This is because swagger is used by default in development. But we have this problem and encountered a 500 error.
For 500 errors, we first look at the code and environment configuration issues at the project level.
It works well locally, there is a problem after publishing, there may be a problem with the parameters of some configuration files.
Once we have determined that there are no problems with the project files, we can only view the problem with the help of application insight and Diagnose and solve the problem.
Finally, you can only delete the current app service resource and recreate an app service with the same name for retesting.
I had a similar issue before, and we solved it by recreating the app service. Later, I also tried searching, and some people said that when creating an app service, you may encounter instances in some areas that are being maintained or updated, resulting in the created app service being in a bad state [The odds are very small].
I think this claim is credible because I once tried opening two Azure portal pages, one of which commits the operation to create the service and the other refreshes the page. In case of not creating successfully, we will see that another page can already see that the service created by the commit is in the resource group.
In short, trying to delete and recreate Azure App Service with confidence that there are no issues with our code is an effective means.
I'm sure this isn't the first time someone asks this, but I tried doing a search and found nothing.
We have an issue with a website, and we've narrowed it down to a timeout issue with an email being sent. So I created a simple webform that sends a test email and I would like to reproduce the error with this new webform..
The issue is that since we publish the website, what's deployed to the production server are precompiled files. I don't want to publish the whole site again just to include one webform with two controls.
How can I just publish one webform? Or how can I precompile just one webform? I don't want to publish the whole site.
Thanks.
You really didn't display any code for us to evaluate perhabs we might see the very source of your problem from the method you're using to send the email.
From experience, using SMTP in ASP Webforms usually crashed the app at some point in the lifecycle. The issue might be from time-outs or from the security configuration of your Website or the hosting enviroment.
I'll recommend you integrate the use of Email APIs to avoid these issues. Sendgrid is a good choice.
Secondly, it appears you have a small test Webform project where you expect to encounter the result again and to maybe adequately analyse the error. I recommend you do not need to deploy this test Webform to your hosting environment because as it would replace the existing site there. While you have the option to pre-compile the site before publishing via FTP, Web deploy does the whole work for you automatically.
It's better you create a different enviroment for testing apps to prevent interference with the live version.
Once you write some server side code, you need the recompile your website and replace the .dll in your bin folder.
I'm learning MVC 4 (Visual Studio Express 2012) and trying to use the new templates that have baked in openId/OAuth external login support. I've been following this tutorial
All I've done so far is create a new MVC 4 internet application with Forms Authentication, and uncommented the OAuthWebSecurity.RegisterGoogleClient(); line in the AuthConfig.cs file.
Changing one line of code from a stock template seems like it should be pretty easy, but when I run the project, I get a "No OpenID endpoint found" exception when I click on the google button.
Keep in mind I have no experience trying to do anything with OAuth/OpenID before.
Does this perhaps have something to do with the fact that I'm running it off localhost on my dev machine? Or some other environment variable like our corporate proxy server/firewall?
I got the impression from this tutorial that you can test this from localhost (at least for Google).
Or is there a different reason for that error?
Before answering, be aware that I do not want to write custom code to get this working. I want to use the stock template.
UPDATE
I tried it at home, and it works no problem on local host. It must have something to do with the network environment at my workplace. Either the firewall or proxy probably. I'd still love to get this working at work though if anyone has any suggestions...
You're following the tutorial correctly, as far as I can see, but it seems a little sketchy on using Google. This has more detail: http://blogs.msdn.com/b/webdev/archive/2012/09/12/integrate-openauth-openid-with-your-existing-asp-net-application-using-universal-providers.aspx and might provide a better step-by-step.
In particular, notice the NuGet packages at the beginning of the tutorial. In addition to getting the necessary .dll assemblies for things to work, NuGet packages often make changes to the Web.Config file, which is where I would expect to find endpoint information for your Oauth provider. If you didn't install all of those packages, you may be missing some configuration settings.
I don't have the specific project templates you're talking about so I can't check: can you post your web.config? There might be something there that needs tweaking.
Oh, and there's also a tutorial on writing your own Google provider, which seems quite straightforward:
http://blogs.msdn.com/b/webdev/archive/2012/08/23/plugging-custom-oauth-openid-providers.aspx
I've had similar issues with OAuth providers on localhost, not ure if this is acctually the reason for your issue, but if I'm doing any OAuth stuff I always make sure I'm running on port 80 and add a line for:
127.0.0.1 www.local.com
to C:\Windows\System32\drivers\etc (you need to open in notepad as administrator),
Then instead of going to http://localhost:1234 just go to http://www.local.com and give that a try. It may not fix the issue, but rules out one more thing,
hope that helps
If you're having this problem at your office only, then proxy might be the issue. Adding proxy autodetection configuration to your project's Web.config file should do the trick:
<configuration>
...
<system.net>
<defaultProxy useDefaultCredentials="True">
<proxy autoDetect="True" usesystemdefault="True" />
</defaultProxy>
</system.net>
</configuration>
I have a website solution that is composed of a Silverlight Project and an ASP Site that contains an asmx Webservice.
The Silverlight project calls various methods in the Webservice, and this works fine on my home PC.
When I publish the site (using 123-Reg if that makes a difference), it appears that the Silverlight app is no longer able to call the webservice. I have tried debugging the app by pointing my local version of the site to my published webservice and I get a "policy" issue.
I know that 123 Reg have .Net 3.5 running on their servers, so I would assume that the site should "just work" when I publish it. Am I making a hugely stupid assumption there? Is there anything that I can do to change the "policies" within my app? Or is there another way around what I am trying to do? I need to keep the webservice, as I want for it to be used from other places, and don't really want to duplicate code and create the same methods within the Silverlight project.
Thanks
Soundlike you are hitting a crossdomain issue, though you shouldn't really.
I would stick a clientaccesspolicy.xml in the root of you web server.
There are loads of questions on SO if you need examples or MSDN
I have just completed my first aspx/c# project using Visual Web Developer Express and consuming some custom controls and external web services. It runs fine on my development machine.
If I now want to test this on a shared hosting account, do I just upload all the files with the current project structure? Will there be any problem uploading the DLLs to a shared Windows hosting account? Anything I should be aware of or changes to be made to the code? Can anyone recommend a cheap and good provider (this is just for testing - no mssql required yet).
Thanks!
Does visual web developer have a "publish website" menu item under the Build menu?
If you want to pre-compile your site and publish it with all dependencies the easiest way I've found. You can then choose to publish it to either an FTP site or the file system. I usually choose the filesystem and then FTP it up myself to make sure I don't overwrite any config files.
If I'm working on a low volume site for a client and performance isn't a problem, I'll just upload my working directory right up to the server so I don't have to deliver the source code separately and I know they won't loose it.
Oh, and one other thing, if you don't configure it special, I would expect you will have to upload your site to the root directory of your hosting account. GoDaddy does have the ability to specify certain directorys as their own ASP.NET application. If you do that you can put your app in a sub-dir of your choosing.
-Al
It would depend on your website provider. You need to get one that supports the .NET runtime. Once you have that, then you simply upload your code and all should work. I personally use www.godaddy.com. You can see an example ASP.NET site hosted by them at www.chessbin.com.
I hope this helps.
Adam
The hosting companies may vary on what they require, but I would think a simple xcopy deploy would be sufficient for most. Here's a link to one that seems to have good prices (disclaimer: I have never used them)
http://www.reliablesite.net/v3/index.asp