ASP.NET 2019 Developer Getting Started
|
ASP.NET 2019 Developer Getting Started |
1. Assuming that you have already run the ASP.NET Web Document Viewer SDK Control installation program and started visual studio 2019, the next step is create a new project, select ASP.NET Web Application(.NET Framework). Click Next.
2. Select Empty - selected Web Forms , click Create button.
3. In Toolbox, Right click the mouse, select Chooses Items... , In .NET Framework Components, select Browse, select WebDocViewerControl.dll from
C:\Program Files (x86)\ASP.NET Web Document Viewer SDK Control\bin folder, then click OK.
4. Select WebApplication1 in Solution Explorer, right click the mouse, select Add - New Items... , select Web Form, enter the Default.aspx name.
then click Add.
5. Select default.aspx in Solution Explorer, selected source tab for view the html code.
6. In Toolbar, select WebDocumentViewer control icon, drag to default.aspx source code.
and We’re also going to use the Width and Height attributes to set the size of the web document viewer, but this is optional.
7. Open Windows Explorer, select "assets", "bigimage", "rotatedimage", "smallimage", "uploads" folder, Drag these folde to your WebApplication1 in Solution Explorer.
After added the folders to WebApplication1 project.
8. Select Web.config, add the following code to Web.config.
<system.web>
<compilation debug="true" targetFramework="4.7.2"/>
<httpRuntime targetFramework="4.7.2" executionTimeout="240" maxRequestLength="900480"/>
<httpHandlers>
<add path="UploadImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerUpload" validate="false"/>
<add path="ConvertImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerConvertImage" validate="false"/>
<add path="GetNumImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerGetDocPages" validate="false"/>
<add path="ExportImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerExportImage" validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="GetNumImage.axd" path="GetNumImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerGetDocPages" resourceType="Unspecified" requireAccess="Script" />
<add name="UploadImage.axd" path="UploadImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerUpload" resourceType="Unspecified" requireAccess="Script"/>
<add name="ConvertImage.axd" path="ConvertImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerConvertImage" resourceType="Unspecified" requireAccess="Script"/>
<add name="ExportImage.axd" path="ExportImage.axd" verb="*" type="WebDocViewerControl.WebDocViewerHttpHandlerExportImage" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
Here is an example of the web.config
If you do not add <system.webServer> tag in web.config when you run the web application in IIS. It will display "There was error uploading files" error message when you upload the file.
If you need to upload big images, you can specify the maximum file upload size supported by ASP.NET at Web.config, The default size is 4096 KB (4 MB)
e.g. add the following code to Web.config, let you upload 100M file size.
<httpRuntime targetFramework="4.7.2" executionTimeout="240" maxRequestLength="102400"/>
e.g.
<system.web>
<compilation debug="true" targetFramework="4.7.2"/>
<httpRuntime targetFramework="4.7.2" executionTimeout="240" maxRequestLength="102400"/>
</system.web>
9. press F5 or click the green color arrow icon to run the project.
10. After run the project, you will see the web document viewer. You can click open button to select the image or TIFF or PDF file.