Search This Blog

Monday, December 12, 2011

URL Rewrite to Remove .aspx in IIS 7 (& DNN

Add this to the <system.webServer> section:

<rewrite>
<rules>
<rule name="RemoveASPX" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="(.*)/default.aspx" negate="true" />
<add input="{URL}" pattern="(.*)/admin/*" negate="true" />
<add input="{URL}" pattern="(.*)/desktopmodules/*" negate="true" />
</conditions>
</rule>
<rule name="AddASPX" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
</rules>
</rewrite>

URL Rewrite to Remove .aspx in IIS 7 (& DNN)


Add this to the section:























Thursday, December 8, 2011

SharePoint solution to deploy InfoPath Form template as administrator approved form template

An InfoPath form template can be published into SharePoint in many ways. Below are the options available to you when you try to publish an InfoPath Form from Microsoft Office InfoPath application.



  • Form Library: You can publish the info path form template as a template in a form library.

  • Site Content type: You can publish this form template into a library in a site collection which will then be accessible by a content type. This content type can be used by multiple libraries.

  • Administrator approved form template: Administrator can upload the form template in central admin form template gallery which can then be enabled into a specific site collection. When a template has been activated in a Site Collection, a copy of the template is stored in Site Collection “Form Templates” library which can be used by multiple sites, libraries within that site collection.



There might be times when you would want to be able to deploy/activate these form templates automatically via a SharePoint solution eliminating the manual processes. In this post, I will show you how you can package an InfoPath Form template into a WSP solution file and deploy it as administrator approved template. This will automatically, upload the template into the Central Admin Form Template gallery and also activate that form template to a Site Collection.


Tools: Microsoft Office InfoPath Designer 2010, Visual Studio 2010 Professional, SharePoint Server 2010


1) Create a new blank form using InfoPath Designer 2010 and add some controls to it. Mine looks like this.



2) Go to form options and in the security section, set the security level to “Domain”. Read more about the security level here.



3) Then you need to publish the form template. Mind you that we are not going to publish this form template directly into SharePoint server. This form template will be automatically published into SharePoint by our solution. So, we will publish this form template into a network location and include it in our SharePoint Solution.


Go to Publish section in InfoPath Designer and choose “Network Location”.




Select the published path with filename. Then go to next step.


Leave the input textbox blank and select next. You will receive a warning but you can ignore it for now.


After publish, you will get a screen like this.



4) You can now verify if this template can be uploaded into SharePoint server using “Upload form template” in central admin site.



select the published form template and then click verify. You should receive a message stating that the template is ready to be uploaded to the server.



5) Create a SharePoint 2010 project in Visual Studio 2010 and select “Module” to be added.



6) Opt to deploy as a farm solution



7) I’ve changed the name of the feature to “InfoPathDeploymentFeature”, “Module1” to “InfoPathFormModule” and also removed the default sample.txt file from the module.


8) Add the published InfoPathForm.xsn file, one we created earlier, under the “InfoPathFormModule” element. Select the xsn file and in the properties windows, under “Deployment Location” property, clear the path value. The Elements.xml file now looks like this.



9) Change the scope of the feature to “Site”. 


10) Double click the feature and in the properties window, set the values for “Receiver assembly” and “Receiver class” as below.


Receiver Assembly: Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c


Receiver Class: Microsoft.Office.InfoPath.Server.Administration.XsnFeatureReceiver




11) Check the SharePoint url where you are deploying this feature. Make sure that the feature “SharePoint Server Enterprise Site collection features” is already activated in that site. You can add feature activation dependency also.



12) Then in the packaging explorer, select the module “InfoPathFormModule”. Then you can add features properties from the properties window. These are very important, if you do not add them, the form will not be uploaded in central admin form templates gallery. The manifest will then look like this.



13) Buid and deploy the project.


Check the form templates in the central admin at this locaiton: Central Admin->General Application Settings->Manage form templates. you will see that the template has been uploaded.



You will also notice this form template has already been activated to the site collection where we deployed the feature.




Go to Site Settings->Site Content Type, you’ll see that a content type by the name “InfoPathForm” has been automatically created. This means that now, we can just add this content type into a form library which we can use to fill out our info path form through browser.


So create a new form library, change it to allow management of content types, and add the “InfoPathForm” content type to that library. The settings of content type will now look like this.



You will now see a new content type option available when we create new document which will open our infopath form in browser. But to enable the infopath forms to be displayed in browser, you need to configure the form library which you can do by setting the value of “Openinig document in browser” to “Open in browser” in settings of the library.



 


14) Lastly, click on the new content type in form library, which will open the info path form in a web page.