Mega Code Archive

 
Categories / ASP.Net Tutorial / Configuration
 

Opening a Configuration File on a Remote Server

Enable the remote server to accept remote configuration connections by executing the following command  from a command prompt: aspnet_regiis -config+ To disable remove configuration connections, execute the following command: aspnet_regiis -config- The aspnet_regiis tool is located in the following path: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe <%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">     protected void btnSubmit_Click(object sender, EventArgs e)     {         try         {             Configuration config = WebConfigurationManager.OpenMachineConfiguration(null, txtServer.Text, txtUserName.Text, txtPassword.Text);             AuthenticationSection section = (AuthenticationSection)config.GetSection("system.web/authentication");             lblAuthenticationMode.Text = section.Mode.ToString();         }         catch (Exception ex)         {             lblAuthenticationMode.Text = ex.Message;         }     } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server">     <title>Show Config Remote</title> </head> <body>     <form id="form1" runat="server">     <div>     <asp:Label         id="lblServer"         Text="Server:"         AssociatedControlID="txtServer"         Runat="server" />     <br />     <asp:TextBox         id="txtServer"         Runat="server" />     <br /><br />     <asp:Label         id="lblUserName"         Text="User Name:"         AssociatedControlID="txtUserName"         Runat="server" />     <br />     <asp:TextBox         id="txtUserName"         Runat="server" />     <br /><br />    <asp:Label         id="lblPassword"         Text="Password:"         AssociatedControlID="txtPassword"         Runat="server" />     <br />      <asp:TextBox         id="txtPassword"         TextMode="Password"         Runat="server" />     <br /><br />     <asp:Button         id="btnSubmit"         Text="Submit"         OnClick="btnSubmit_Click"         Runat="server" />     <hr />     Authentication Mode:     <asp:Label         id="lblAuthenticationMode"         Runat="server" />     </div>     </form> </body> </html>