asp.net में रनटाइम पर web.config फ़ाइल में टिप्पणी कैसे जोड़ें

प्रोग्रामिंग


प्रिय साथियो,

नमस्ते, मैं रनटाइम पर अपनी web.config फ़ाइल में कुछ टिप्पणियाँ जोड़ना चाहता हूँ।
उदाहरण के लिए मतलब

मूल Web.config फ़ाइल है:

सी#
<pre lang="xml"><?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
    <appSettings>
  <add key="customsetting1" value="Some text here" />
  <add key="myKey" value=",1,1,1,1,1,1" />
  <add key="RemoveTCPError" value="1,1" />
 </appSettings>
    <connectionStrings>
  <add name="myDatabaseName" connectionString="whatever" />
 </connectionStrings>
    <system.web>
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="true"/>
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows"/>

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>

    </system.web>
</configuration>

इसे संशोधित करने के बाद कुछ बटन पर क्लिक करें :

एक्सएमएल
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->

<!--
    Note: As an alternative to hand editing this file you can use the
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->


<configuration>
    <appSettings>
  <add key="customsetting1" value="Some text here" />
  <add key="myKey" value=",1,1,1,1,1,1" />
  <add key="RemoveTCPError" value="1,1" />
 </appSettings>
    <connectionStrings>
  <add name="myDatabaseName" connectionString="whatever" />
 </connectionStrings>
    <system.web>
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="true"/>
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows"/>

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>

    </system.web>
</configuration>

या web.config फ़ाइल में कहीं भी कॉमनेट जोड़ा जाना चाहिए या किसी भी टिप्पणी वाले भाग में टेक्स्ट जोड़ा जाना चाहिए।
क्या यह संभव है।
कृपया मेरी मदद करें।

सभी को अग्रिम धन्यवाद।

सम्मान,
रंजीत वाजे

समाधान 1

web.config फ़ाइल में कहीं भी कॉमनेट जोड़ा जाना चाहिए या किसी भी टिप्पणी वाले भाग में टेक्स्ट जोड़ा जाना चाहिए।
क्या यह संभव है।

संभव, हाँ! लेकिन मैं ऐसा करने का सुझाव बिल्कुल नहीं दूँगा।

Web.Config एक कॉन्फ़िगरेशन फ़ाइल है जिसके आधार पर आपकी वेबसाइट चल रही है। कॉन्फिग फ़ाइल को संपादित/अपडेट करने के लिए किसी को भी (यहां तक ​​कि व्यवस्थापक को भी) अनुमति देने के लिए आपके एप्लिकेशन पूल को पुनरारंभ करने की आवश्यकता होगी जो कि एक समस्या होगी यदि कोई व्यक्ति उसी समय कहीं और आपके ऐप से जुड़ा हो। इसके अलावा, कॉन्फ़िगरेशन फ़ाइल में “टिप्पणी” जोड़ना कहीं भी महत्वपूर्ण या आवश्यक सुविधा नहीं लगती है।

यदि आप अन्यथा सोचते हैं, तो बस कॉन्फ़िगरेशन फ़ाइल ढूंढें/पता लगाएं, और नोड ढूंढें और इसे सामान्य एक्सएमएल के रूप में अपडेट करें। सुनिश्चित करें कि आपके पास फ़ाइल को संपादित/अपडेट करने की अनुमति है।

समाधान 2

पर एक नजर डालें WebConfigurationManager कक्षा[^]. बदले में यह वर्ग दूसरे तक पहुंच प्रदान करता है कक्षा[^], Configuration जो आपको कॉन्फिग फाइलों पर काम करने और उन्हें संपादित करने की अनुमति देगा।

コメント

タイトルとURLをコピーしました