I have a wcf service application that has some application startup code in the app_code folder of the project. When i publish this project to my website, it deploys it with source code and app_code folder.
Is there a way to precompile the wcf app ( like an asp.net app), that includes all the dependencies and compiled code ?
i checked the web deployment package files, and even that has the source code of app_code folder.
problem here really is that since the template for wcf does not expect app_code folder and .cs files in it, they get added as content, changing them to compile would include them in the web dll
Your best bet would be to:
put all your WCF service-related code into a separate class library assembly
deploy that assembly to the .\bin directory
only put your MyService.svc file (without any code-behind) to your virtual directory
With this setup, the WCF service is still being hosted by IIS, but you don't need to do any special tricks and hacks to get it to work properly.
Related
I have two separate .NET6.0 projects for back-end and front-end. Backend with C# can be published just fine. Front-end is written with Blazor. When I choose publish, it goes through the process without errors or exceptions. It also builds files in the bin>Release>net6.0 directory just fine but doesn't create any of the DLL files in my chosen directory for publish. In that directory, it just creates wwwroot, libman.json and web.config as you can see in the image.
Where can be the cause of the problem?
blazor web assembly app is a static app so it will have much static files, the logic codes you wrote in .razor will be packaged into your_project_name.dll in wwwroot\_framework.
Then when we need to host the app, we need to find a static file server to serve the app. For example, IIS. When publish the static app, we need to create a website and set the website point to the publish folder which containing wwwroot folder and web.config file. Then make sure the IIS had installed url rewrite module since it's a static website. After installing the module, we will see the default rewrite rule like this:
I created empty project asp.net 5 in Visual Studio 2015.
Here how it looks:
As I understand from some tutorials the bin folder have to be inside wwwroot.
But there is no bin inside wwwroot and also bin folder not exists anywhere in Sensor Observation project.
Any idea why bin folder not exists inside wwwroot in my project?
The wwwroot folder is from where you serve static files (e.g. css, images, JavaScript, etc.). Files in the bin folder should never be served to the client (e.g. browser) so it should not go in the wwwroot folder.
Here is some more information on what the wwwroot should contain. Essentially:
"Enter the wwwroot folder in ASP.NET 5. The wwwroot folder represents
the actual root of the web app when running on a web server. Static
files, like appsettings.json, which are not located in wwwroot will
never be accessible, and there is no need to create special rules to
block access to sensitive files. Instead of blacklisting access to
sensitive files, a more secure whitelist approach is taken whereby
only those files in the wwwroot folder are accessible via web
requests."
The wwwroot/bin folder only used to contain one single file AspNet.Loader.dll. The AspNet.Loader.dll was/is used by IIS to load the application (which resides outside of the wwwroot folder).
The reason for this is an increase of security. With ASP.NET Core 1.0 you don't point the application entry to the folder (that contained all the *.cs files in ASP.NET 4.5), but you point it to the wwwroot folder of your application.
Now IIS don't has access to the actual application files (and allow by accidental access to maybe sensitive files). So the AspNet.Loader.dll is required to execute your application.
Other than that, there are no other binary files in wwwroot/bin nor should there be any other.
Update:
This used to be required for Helios to be run/hosted within IIS. Helios has been deprecated with beta8, because it made no sense to develop two different servers. So wwwroot/bin will always be empty for newer versions of ASP.NET Core. If you found posts or references, they most likely reference to an old beta.
Now Kestrel, IIS via HttpPlatformhandler (up to rc1-final version and ASP.NET Core Module with rc2 and newer) and self-hosting via HttpListener are the supported run modes. Though one can also use Kestrel behind an IIS.
What files do i need to put in iis directory when deploying wcf web service in iis adding as site?
For example:
Is it just dll from bin and service contract?
Does example.cs code files need to be copied in iis directory too?
It depends what you have in your service.
Usually, the bin folder, the configuration file and .svc file, if it exists.
But it's better let Visual Studio handle this. Right click over your service project and then "Publish". Visual Studio will copy everything you need to deploy to a folder.
I have a very simple ASP.NET MVC 4.0 website. It's got a single controller ("HomeController") with a single action ("Index") which receives a single parameter ("string id"). I have not modified the global.asax file since this kind of route is handled by default. I have not created a view for this action since the action will simply be "sending" the user a file (a PDF). If I run the site from within Visual Studio (using a default page of "home/index/3" in project properties), the page runs fine. If, however, I publish the site to our test server (https://ourserver.com/mysite/home/index/3), I get a 404--File or Directory not found.
NOTE: We're running IIS7.5 on this server.
UPDATE: The bin dir (and the appropriate DLL, i.e., one named after the project) and the web.config file are there.
So, why is this not working?
If you're using an older version of IIS and haven't installed the MVC server extensions which give you routing, you can do a BIN deployment of the necessary infrastructure files.
Edit: If you're running IIS 7.5 you should have everything you need. You mention you don't see a web.config file or any dlls - how did you publish? You should absolutely have a web.config at the root of the publish directory and a bin folder with your dll(s).
If you right-click on your web project and do Publish, you can publish to a local directory. It'll be exactly what you should see when deployed.
Edit 2: Did you check that it's configured in IIS as a web application and not just a site?
I restructured a WCF project to separate the service.cs and contracts to separate projects. In the main WCF project I place only a service.svc file that references (dll, not service reference) the service class. I also updated app.config to reflect the change.
Once I do this, the wcf test client no longer loads the service. It gives no errors. I can publish to my local IIS and it still works just fine.
Do I need to add something to the wcftestclient.exe command line options?
Is the dll of the project that has the contracts in there also? Make sure to copy everything from the bin/debug (or bin/release) into IIS virtual directory.