How to merge C# webpages in vb.net web application - c#

I have an existing vb.net web application, I want to add some C#.net web pages in that application. I don't want to create subsite for that pages.

It is possible and we are also managing some projects which has 2 languages(VB,C#) for web application.
What i suggest is to copy the vb web page to the project folder and include them to project.(include .vb,.designer.vb)
now just build the application and set the start up page as the newly added vb web page.
I hope it should work.
cheers.:)

Related

Reference web config of parent project to child project in same Solution

I am having an existing website which contains two directories a website and a class library file.
now am trying to add new web application to this,when I added it creates a web config for it.
How can i reference my new web application to refer from my website
For your reference,If I am doing something wrong please guide.
Thanks
Askar
You cannot reference a web application to a website.
If it is needed that you cn make calls via Service reference or ajax calls.
But you might have an issue with CORS than.
the question is why are you trying to put in one solution a web application AND a web service.
I think you should have one web application from which you create all the controls you need and refer the needed class libraries

Can CSHTML files run directly?

I'm just started asp.net using Razor V2 syntax. While I'm developing in Visual Studio, everything is fine however when i try to run .CSHTML files directly from browser, they do not work.
I want to know are .CSHTML files are intended to run directly or they must be used in other segments of web applications which can not be called by browser directly?
Yes - cshtml pages can be run directly. If you build an ASP.NET Web Pages (Razor) site, you can request .cshtml pages directly and they will be served (unless the file name starts with an underscore).
You can build a Razor Web Pages site by going to File » New » Web Site. You can get more information about ASP.NET Web Pages from here: http://www.asp.net/web-pages. It is the recommended starting point for people who are new to ASP.NET development.
[UPDATE]
They can also be run directly when used as part of a Razor Pages site which was introduced in ASP.NET Core 2.0.
By default mvc blocks access to views using an http handler in web.config.

convert web application to a web site

I have a c# .net VS2010 web application that contains only classic asp files.
What I want to do is convert the web application to a web site to make it easier to manage the classic asp files.
How can I convert from web application to web site? I have researched google and found lots of examples going the other way.
I don't think there's an automated way to do this. You could just create a new website in Visual Studio and copy your files from the web app into this new website. Be sure to go into each and every .aspx/.ascx file and edit the 'Codebehind' attribute so that it reads 'Codefile' (codebehind directive needs to be compiled and thus won't work in an ASP.NET website). You'll also need to delete the Designer/Designer.cs files.
Hopefully you don't have too many files so that this won't be too much of a PITA.

Sharepoint - Integrate c# application

iam new to sharepoint. I have an application created in C#. Now i have to upload to sharepoint portal server and need to create a link in documents tab which will open this application.
If you are simply trying to show the contents of one web page inside of SharePoint then you can use a "Content Editor Web Part". You set the URL of the web part and the web page is displayed inside of an iFrame on your SharePoint page.
If you have an existing C# solution, you could either put that inside a web part or create an application page for it: http://msdn.microsoft.com/en-us/library/ee231581.aspx

My existing webparts won't work in SharePoint

I have a standard ASP.NET 2.0 website.
It has a webpage page.
I have a webpart in my Company.Web.dll that I display on my webpart page on my website.All is good!!!
I would like to use this same webpart in SharePoint 2007.
I have a "site definition" project in VS2008 using Extensions for SharePoint 1.2. I have tried various ways to add the webpart from an outside assembly to my site definition. I have been able to deploy the webpart (where it is added to the webpart list of a webpart page) but I have been unsuccessful at adding the it to a page.
My Glorious Failures:
Created a shell webpart to just display the existing web part, basically just using my part as a control.
Attempted to modify the X.webpart and X.xml files created by VS2008 when you create a new webpart.
Both result in the following error while adding the web part to the page:
Exception
Microsoft.SharePoint.WebPartPages.WebPartPageUserException:
Cannot import XXXX Web Part.
at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean
clearConnections) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, Uri webPartPageUri,
SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
Is there a special way I need to add my existing webpart to my site definition?
This sounds like a problem resolving the GUID at deployment time, as you can read about in this SO question.
To find the details of why the web part won't import, check the ULS logs. These are typically located at %CommonProgramFiles%\Microsoft Shared\web server extensions\12\LOGS. An entry will be logged here at the time you attempt to add the web part to the page. This should give you more detail.
My guess is that it is a code access security issue. Your web part must be strongly signed and needs a SafeControl entry in the web.config of the SharePoint web application. Apart from these things you should be able to just add it to the Global Assembly Cache to test if it works (best practice is to write a CAS policy file). See Deploying Web Parts in Windows SharePoint Services for more details.
I would try these steps before trying to integrate it as part of a site definition. Then at least you know the web part will actually run.
Also, VSeWSS is really designed for developing your web part using it from the very start. If you have the original source, you could try creating a new web part with VSeWSS and then replace with your custom code and update the .webpart and feature XML files. Then it should behave a little better. If you haven't committed to VSeWSS, try WSPBuilder as it's less painful.
ASP.NET webparts and Sharepoint Webparts are NOT the same. You should be able to use a ASPNET webpart within Sharepoint. See the following table:
ASP.NET 2.0 Web Part
For most business needs.
To distribute your Web Part to sites that run ASP.NET 2.0 or SharePoint sites.
When you want to reuse one or more Web Parts created for ASP.NET 2.0 sites on SharePoint sites.
To use data or functionality provided by Windows SharePoint Services 3.0. For example, you are creating a a Web Part that works with site or list data.
SharePoint-based Web Part
When you want to migrate a set of Web Parts using the SharePoint-based Web Part infrastructure to Windows SharePoint Services 3.0.
To create cross page connections.
To create connections between Web Parts that are outside of a Web Part zone.
To work with client-side connections (Web Part Page Services Component).
To use a data-caching infrastructure that allows caching to the content database.
For a Sharepoint webpart to work in a standard ASPNET application you would need to recreate your webparts in Visual Studio (as an ASPNET webpart) without the Sharepoint 2007 references for it to work correctly.
One nifty tool which I have used in the past is the SmartPart Worth checking out:
This lets you create a ASP.NET usercontrol (visually) in Visual Studio and then host this in Sharepoint. The smartpart acts as a wrapper wepart for your user control. Think of it like the page viewer webpart in Sharepoint except instead of it being HTML pages its ASP.NET UserControls.
You would need WSS 3.0, SharePoint MOSS or 2007 to use ASP.NET 2.0 WebParts. SharePoint 2003 or below and WSS 2.0 or below do not support ASP.NET WebParts.

Categories