Referencing code in VB.NET - asp.net

I'm not at all familiar with VB.NET or ASP. I need to create a simple page which makes a call to a remote web service. I used the wsdl utility which comes with the DotNet SDK to generate a service proxy and write it to a VB file. Unfortunately I have no idea how to reference this code in either my ASPX file or the code behind VB file so I can create an instance of the proxy.
Edit: I should have qualified this by noting that I'm not using visual studio. I just coded up a .aspx with a .vb behind it and dropped it into an IIS location. Is there a way to do what you're suggesting outside of VS?

You need to add this code into your project so that it can be consumed.
Right click on your App_Code folder and select "Add Existing Item". This will bring up explorer. Use it to select the generated file and it will add it to your project.
Now you will be able to reference this code from within your page or code behind file
If there isn't an App_Code folder in your project, then right click on the project in solution explorer and select "Add New ASP.Net Folder"->App_Code

Or, instead of the wsdl utility:
In the solution explorer windows, r-click on the project, and select "add web reference". In the dialog that comes up, put in the url to the web service. In the web reference name box (lower right of that dialog), put in whatever you want to local alias for the service to be called.
So, if you put in a url of:
http://otherserver.com/otherservice.asmx
And, a web reference name of:
xyz
To use it, your code would look like:
dim x as new xyz
var = x.methodname()

Related

Adding global.aspx file

I am currently using IIS to host a simple website, and would like to know how to enable the 'Global.aspx' file? I need to know where I would define it, as all the tutorials talk about using Visual Studio, which I am not using.
File Global.asax should be placed on the root directory of your site. There is nothing else to do besides adding required code, you put it there and just work.
Just right-click on the project name displayed in the Solution Explorer, and choose Add New..., then choose Global.asax from the list displayed in the new popup window. It goes to the root of your application.
Here is further information: Where is the Global.asax.cs file?

How to add global.asax file to ASP.NET MVC4 project?

In my project the Global.asax file is removed. I want add a global.asax file to my projet.
But in Add New Item dialog the Global.asax not exist.
Just in case you may have missed the item even though it may actually be there for you I'll post this answer.
In Visual Studio 2013
Open Solution Explorer.
Right-click on the project.
Add New Item.
VB or C#
Web.
General.
Global Application Class.
Create an empty new project.
Go to that folder and copy the Global.asax file.
Go to your project and in solution explorer paste it on root.
Open Global.asax file and change namespace match to your namespace.
In solution explorer right click on Global.asax and pick View Markup and change inherits match to your namespace.
Any problem doing this:
Create a new empty project and get it from there (drag-and-drop from Windows Explorer to Visual Studio works fine), or
Add, say aspx page or any item, then rename accordingly (to get the code behind file, add and rename another item); in this case, they'll obviously be empty.

Update asp.net WebService reference from wsdl file?

Is it possible in asp.net to update or create a web service reference from a wsdl file on our local drives?
If so, could you please describe it ?
Follow these steps.
Open the Solution/Project in Visual Studio
Right Click on Solution Explorer on the project for which you want to add web reference.
Select Add Service Reference. (This will open a Add Service Reference dialogue box.)
Click on Advanced... button located at bottom of the dialogue box. (This will open another dialogue box named Service Reference Settings.)
Click on Add Web Reference button located at bottom of the dialogue box. (Again a dialogue box Add Web Reference would appear.)
Enter OR Copy & Paste full path for the WSDL file from your local drive as the URL.
Click on Go button besides the URL box.
Edit Web Reference Name if you want to.
Click on Add Reference.
And you are done.
It's been long time from accepted answer. If you are using VS2019 you can simply click on the service and select "Update..."
No need to add the service as Web Reference. You can do it setting the "Address" Field as the path of the file, for e.g.:
c:\contracts\mycontract.xml
and then "Go".

two problems with Web Site type project (not Web Application)

I have a project which is a Web Site, not Web Application and have two problems because of that.
I have a custom control derived from BaseValidator which I had to put in the App_Code folder. Now on the page I want to register this control by
<%# Register tagname="mytagname" Namespace="PP" TagPrefix="dv2" %>
But when I get enter to this page, I have exception, because the src attribute is missing. I can't put in the src attr. path to the App_Code because I have another exception. How can I do that? This is a Web Site, so the sources are not compiled to one dll file, so I don't know what to add to the src attribute.
When I want to add to the Web Site a new project library, I have to compile it and manually copy the library dll file to the bin folder in the Web Site. But don't know, how can I debug this library with brakepoints?
This is my first time with Web Site project type. I always created the Web App.
1- Don't use tagname attribute here, tagname is suitable for UserControls.
http://msdn.microsoft.com/en-us/library/c76dd5k1.aspx
2- There is no any difference between using library in a web app or website. Just choose Add Reference from project node's context menu and select your class library from project tab.
Try creating a separate project for your CustomControls and reference it in your WebSite project by the namespace you use in your CutomControls project. Also check out this post for some information asp.net add custom control in website
Your second question, if you keep all of your projects in the same solution and just reference them to each other's projects, you will be able to debug and step into methods and set break points in any of the projects in your solution. If you don't want to do that, you have to copy the debug symbol files along with the .dll to the bin or point VS to where the necessary debug symbol files are located and then you will be able to step through the code in the .dll

How do I download an msi file via an asp.net button?

So, I've created my wonderful winforms app that I want to unleash upon the world, and now I am trying to create a simple website to host some basic information and link to the setup file (msi installer file )....
I have a button on the asp.net page and the setup file setupApp.msi in same folder as the asp.net page. I am currently trying the following:
Response.Redirect("http://./SetupApp.msi");
But this best guess at what to do is not working. Is there something wrong with Mime types here? What do I need to put in the click event to allow users to download this file?
The path you are passing in to the method is not valid (there's no server name called ".").
You can pass in a relative path and it should work fine because ASP.NET will resolve the path:
Response.Redirect("SetupApp.msi")
Or if it's not in the same folder, try one of these:
Response.Redirect("../Downloads/SetupApp.msi")
Response.Redirect("~/SomeFolder/SetupApp.msi")
Keep in mind that you don't necessarily have to do the whole redirect at all. Instead of writing code in an ASPX file you could just have a link to your MSI:
Download my app!

Resources