locked
Creating sharepoint webapplication using Asp.net RRS feed

  • Question

  • Hi,

    I have created sharepoint web application using C#. After created web application , i have notified the virtual directory is created with caption as some random number (eg Port no : 4000 , but virtual directory folder is 15456). PFB my code

    using Microsoft.SharePoint.Administration;

    SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local);
    SPWebApplication newApplication;
    int myPort = 4008;
    string spuser = "DomainName\username";  // should have admin access for this id
    webAppBuilder.Port = myPort;
    webAppBuilder.ApplicationPoolId = "Sharepoint-" + myPort.ToString(); // application pool
    webAppBuilder.ApplicationPoolUsername = spuser;
    webAppBuilder.ServerComment  = "Sharepoint - " + myPort.ToString();  // IIS creating Website name
    System.Security.SecureString password = new System.Security.SecureString();
    string strName = "Password";
    char[] pass = strName.ToCharArray();
    foreach (char c in pass)
        password.AppendChar(c);
    webAppBuilder.ApplicationPoolPassword = password;
    webAppBuilder.CreateNewDatabase = true; // Create new database
    webAppBuilder.DatabaseName = "Test_" + myPort.ToString()+"DB"; // database name
    webAppBuilder.DatabaseServer = webAppBuilder.DefaultZoneUri.Host; //Host name/computer name
    webAppBuilder.UseNTLMExclusively = true; // Use NTLM authentication
    newApplication = webAppBuilder.Create(); // Create new web application
    newApplication.Provision();

    Please help how to create the same port number is a virtual directory folder caption?.

    Regards,

    Ravikumar.N

    • Moved by Caillen Thursday, August 29, 2013 11:51 AM
    Wednesday, August 28, 2013 10:03 AM

All replies

  • You should post to the MSDN ASP.NET forum.

    Wednesday, August 28, 2013 10:15 AM
  • Hi,

    Please post your question in ASP.NET forum, you could get help from more experts there.

    Thanks for your understanding.


    Caillen
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 29, 2013 11:51 AM