Sitecore Forms 9.2与WebForms兼容性及非MVC渲染问题咨询
Rendering Sitecore Experience Forms in Web Forms (Non-MVC) Applications
Yes, Sitecore Experience Forms can be rendered in Web Forms-based applications. Here are the proven methods to implement this, along with key considerations:
1. Use the FormWebControl (Declarative Approach)
Add the Sitecore Forms Web control directly to your .aspx page:
<%@ Register TagPrefix="sc" Namespace="Sitecore.Forms.Web.UI" Assembly="Sitecore.Forms.Web" %> <!-- Replace {YOUR-FORM-ID} with the GUID of your Experience Form item --> <sc:FormWebControl ID="SitecoreExperienceForm" runat="server" FormId="{YOUR-FORM-ID}" />
- Required Assemblies: Ensure your project references these binaries (included with the Sitecore Forms module):
Sitecore.Forms.Core.dllSitecore.Forms.Web.dllSitecore.Mvc.dll(Experience Forms relies on some MVC components even for Web Forms environments)
2. Dynamic Loading via Code-Behind
For scenarios where you need to load forms dynamically (e.g., based on page context), instantiate the control in your code:
using Sitecore.Forms.Web.UI; protected void Page_Load(object sender, EventArgs e) { var formControl = new FormWebControl { FormId = new Guid("{YOUR-FORM-ID}"), ID = "DynamicExperienceForm" }; // Add the control to a placeholder in your .aspx page FormContainer.Controls.Add(formControl); }
In your .aspx page, add a placeholder to host the control:
<asp:Placeholder ID="FormContainer" runat="server"></asp:Placeholder>
Critical Configuration Checks
- Confirm
Sitecore.Forms.configand related forms configuration files are deployed and enabled in your Sitecore 9.2 instance. - Verify your
web.configincludes necessary handlers for Sitecore Forms (look for entries under<httpHandlers>and<handlers>for paths likesitecore/api/forms/*). - Ensure form submission actions are properly configured—most standard actions work in Web Forms environments, but custom actions may need adjustments to avoid MVC-specific dependencies.
Troubleshooting Tips
- If you encounter MVC-related exceptions, double-check that
Sitecore.Mvc.dllis present in your bin folder and referenced. This is a common oversight. - Review Sitecore logs for detailed error messages—issues often stem from missing form items, incorrect item permissions, or misconfigured validation rules.
内容的提问来源于stack exchange,提问作者Parry Brookes
相关产品推荐
相关产品推荐

