I'd like clarification of what seems to be a contradiction in MSDN documentation.
MSDN makes very clear the distinction between a "web site" and a "web application." For example, it says you should use an "application" instead of a "site" if...
You want to avoid putting source code on a production server.
Ok, sounds good, but when you create an ASP.NET MVC "app" or a WCF service "app", the first thing you get is a description file with a CodeBehind that specifies what source code to reference. Examples:
For ASP.NET MVC
<%# Application Codebehind="Global.asax.cs" Language="C#" Inherits="Sample.MvcApplication" %>
For a WCF service app
<%# ServiceHost CodeBehind="MyService.svc.cs" Language="C#" Service="Sample.MyService" %>
In both these "app" examples, the "CodeBehind" assumes you have placed source code on your production server. In short, what you receive from a Visual Studio "App" or "project" template basically contradicts the claim made by MSDN documentation.
What makes this more strange is that, at least in some caes, this doesn't need to be this way. For example, another valid way for the WCF service description file to be generated is like this:
<%# ServiceHost Language="C#" Debug="true" Service="Sample.AccountService" %>
<%# Assembly Name="Sample.AccountService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" %>
With the "Assembly" directive, it is not necessary to specify a CodeBehind target. If a purpose of a WCF app (in contrast with a WCF site, which is also a Visual Studio option) is to have no source code on a production server, why then is the service definition file not generated as shown in the last sample above?
What is the rationale that allows this apparent contradiction?
You want to avoid putting source code on a production server.
This is referring to the ability use non-compiled code. With a website, you have the ability to copy your aspx.cs or aspx.vb files (in clear text) along the aspx files and have them run. You can also modify them in clear text because they are not compiled.
A web application differs because must be compiled, the source code exists in DLLs.
Related
I've been experiencing this issue on my Web App. The line throwing the error is:
Line 1: <%# Page Language="vb" AutoEventWireup="false" Codebehind="foo.aspx.vb" Inherits="foo" %>
Things to note:
This was a working web application on .NET 2.0. I wanted to migrate it to .NET 4.0.
The codebehind file exists.
The Partial class in the Inherits attribute exists.
The .dll's are updated in the bin\ of the project and in the bin\ of wwwroot.
I have been to multiple sites and similar questions here in StackOverflow, but the solution suggested are always to check the items in the list above.
I am not sure about your Inherits attribute value in below line
<%# Page Language="vb" AutoEventWireup="false" Codebehind="foo.aspx.vb" Inherits="foo" %>
Inherit attribute contains the full namespace path. So go to your code behind file and check the namespace in which foo class exists. It may be exists in your project namespace. Like if your project name is MyProject then it should be something like this MyProject.foo
<%# Page Language="vb" AutoEventWireup="false" Codebehind="foo.aspx.vb" Inherits="MyProject.foo" %>
Go to IIS:
Change your web application pool framerwork from version .NET 2.0 to 4.0
I am having trouble getting my AJAX control tool kit working in asp.net. The website runs fine when I run it using the localhost/website.aspx address however when I attempt to access the website via the net I get the error below. Any Suggestions?
Parser Error Message: Could not load file or assembly
'AjaxControlToolkit' or one of its dependencies. The system cannot
find the file specified.
Line 1: <%# Page Language="VB" AutoEventWireup="false"
CodeFile="Submit_Employee_Info.aspx.vb" Inherits="_Default"
MaintainScrollPositionOnPostback="true" %>
Line 3: <%# Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="asp" %>
Source File: /RequestForm/Submit_Employee_Info.aspx Line: 3
Sorry not much reputations so posting as answer instead of comments. Do you have ajax toolkit dll referenced in your project. To confirm, check your bin/debug director.
In your local solution, expand the references folder in the web application, and find the AjaxControlToolkit.dll.
Right click, Properties, and check the path to where the DLL is referenced
If it's referenced to a folder outside of your project, you will need to include this in the project.
You have a couple of choices...
Copy DLL into a 3rdPartyLibs folder in the solution, and change the reference to point here
Use Nuget to download the file into the solution, the only issue here is that the version may be incorrect, so option 1 here might be best in your scenario.
I have a "Data view web part" created from SharePoint Designer. I added the web part to my visual studio project as a "Web Part" . I want to know how to add the web part to an application page.
Hi i know its kind of late but, today i had to do the same thing, so i followed a great answer on sharepoint.stackexchange.com. But basically is like adding any other asp.net control on an APS.NET page.
First you need to define the prefix for that assembly
<%# Register tagprefix="prefix" namespace="NameSpaceOfTheWebPart" assembly="FullAssemblyName" %>
ex:
<%# Register tagprefix="csm" namespace="MySolution.VisualWebPart" assembly="MySolution Version=1.0.0.0, Culture=neutral, PublicKeyToken=335eef5f6f60e56b" %>
and then add the web part to the page (on the main place holder) using the required attributes by asp.net (ID and runat).
<prefix:WebPartClassName ID="ID" runat="server" />
The only thing is that you won't be able to edit the page and modify the Web Part through the browser, if you need to modify any other property of the Web Part you will have to do it from the html or code behind.
here is the url of the link i followed:
https://sharepoint.stackexchange.com/questions/26508/is-it-possible-to-add-web-parts-to-an-application-page
i hope it helps.
If you precompile a web site and keep it updatable, the ASP.NET parser can see from the Page directive that there is no codefile or codebehind and where to find the base class (inherits attribute).
<%# page language="C#" autoeventwireup="true" inherits="_Default, Precompiled"
theme="Default" validaterequest="false" %>
If the site is precompiled and not updatable, the .compiled files in the bin folder should give the ASP.NET runtime all the necesary information on how to instantiate the page classes.
So why is the precompiledApp.config needed?
Thanks!
It's used to indicate whether or not the ASPX/ASCX pages in your site are updateable or not. You can precompile and have the code behind compiled, but leave these pages updateable so you can make minor GUI-related tweaks should you wish.
I tried to bring a previously done webform made in vb.net to an IronPython asp.net website with no luck. After seeing it didnt work, I tried to write the simplest codebehind vb.net webform to see if there was a problem with vb.net in an IronPython website and I got the following usual error
"be sure that the defined class in this file matchs with the one in the attribute inherits and that it extends the right base page (page or control)" (sorry if the translation isnt the most accurate I get that message in spanish)
but if I create a vb.net webform in the same website, with the sourcecode in the same file (with the vb.net code between script runat="server" tags in the same page) I get no problem.
Do I have to configure something for both kind of sourcecode languages to run in such way in the same IronPython website, like configuring something in the webconfig file or is there some compatibility issue for doing that which can't be resolved?
The code between <script /> tags is compiled dynamically when the page is first run. This enables you to mix languages. However, the classes in your code-behind files are statically compiled into an assembly by VS.NET ... and a VS.NET project can only support one language at a time.
One solution is to put your VB.NET code-behinds in a separate assembly. For example:
Add a new VB Class Library project to your existing solution
Add a reference to System.Web
Create your VB.NET code-behinds. They should be normal classes inheriting from System.Web.UI.Page.
In your ASP.NET website project, add a reference to the new project
Edit the # Page directives in your *.aspx files to inherit the classes in the new project
e.g. <%# Page Inherits="YourNewVBClassLibraryProject.MyVBCodeBehinds" ... /> where the Inherits attribute contains the relevant namespace-qualified class name
Thanks for the reply Serilla. Your information was interesting but I simply solved it by creating the app_folder and adding the vb files there. Do you think I could have some future problem for doing so?
The problem with the vb files was when these lines in the web.config were enabled for Ironpython to work
<pages compilationMode="Auto" pageParserFilterType="Microsoft.Web.Scripting.UI.NoCompileCodePageParserFilter" pageBaseType="Microsoft.Web.Scripting.UI.ScriptPage" userControlBaseType="Microsoft.Web.Scripting.UI.ScriptUserControl">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
when I removed them, vb code behind files worked but ironpython didnt. When the lines were there, Ironpython code behind files worked but vb ones didnt