Return HTML response from Web Service in ASP.Net

Last Reply 11 months ago By Mudassar

Posted 11 months ago

I want to return html response using web service .how can i achieve this.?

Posted 11 months ago

Hi iammann,

Creating a web method which returns a string value that contain the HTML string.

Example

[WebMethod]
public string GetHTML()
{
    return "<HTML><TITLE>...";
}

 


Posted 11 months ago

thanks for the anwers .but its returning an XML node.i just want to return simple HTML  i dont want XML nodes in the response.


Posted 11 months ago

Will you please provide sample html that you want to return.


Posted 11 months ago

 

<table width="100%">
                <tbody><tr>
                    <td colspan="2" style="border-bottom: 1px dotted #862D01; color: #862D01; font-size: 13px; font-weight: bold;">Power Generation as on  : <b></b>
                        <span id="txtDateofEntry">05/04/2018</span>
                        &nbsp;  at
              <span id="lblTimeEntry" style="float: right">07:00AM</span>
                    </td>


                </tr>
                <tr>
                    <td class="style4">Anpara           </td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="txt_Anpara">2214</span>&nbsp;MW
                    </td>
                </tr>
                <tr>
                    <td class="style4">Obra
                    </td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="txt_Obra">417</span>&nbsp;MW
                    </td>
                </tr>
                <tr>
                    <td class="style4">Panki
                    </td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="txt_Panki">0</span>
                        MW
                    </td>
                </tr>


                <tr>
                    <td class="style4">Parichha     </td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="txt_Parichha">586</span>
                        MW
                    </td>
                </tr>
                <tr>
                    <td class="style4">Harduaganj
                    </td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="txt_Harduganj">202</span>
                        MW
                    </td>
                </tr>


                <tr>
                    <td class="style4">Total&nbsp;Generation
                    </td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="lbl_sum">3419</span>
                        MW
                    </td>
                </tr>
                <tr>
                    <td class="style4">Thermal Backing</td>
                    <td style="font-size: 12px; color: White" align="right">
                        <span id="lbl_pwrBacking">1344</span>
                        MW</td>
                </tr>
                <tr>
                    <td class="style2">&nbsp;
                    </td>
                    <td>
                        <span id="lblMessage"></span>
                    </td>
                </tr>
                <tr>
                    <td class="style4">&nbsp;
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td class="style4">&nbsp;
                    </td>
                    <td>&nbsp;
                    </td>
                </tr>
            </tbody></table>

 


Posted 11 months ago

WebService always returns data wrapped in SOAP XML and hence if you don't want that. Use a WCF Service.