D
D
Dmitry Filandor2016-10-24 11:01:28
ASP.NET
Dmitry Filandor, 2016-10-24 11:01:28

Why is the route not working?

Hello!
I want to get rid of Home in the URL
In the route config I set:
routes.MapRoute(
"meropriyatiavnikolaeve",
"meropriyatia",
new { controller = "Home", action = "meropriyatiavnikolaeve" }
);
in controller:
public ActionResult meropriyatiavnikolaeve()
{
BusinessLayer.Events.EventsManager EventsManag = new EventsManager();
ViewBag.EventsMain = EventsManag.EventsToday();
returnView();
}
everything seems to be correct, it works in other projects, but here it stubbornly opens localhost: and
Sollyushin cleaned everything, collected
what he added to the config:

<appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="PluploadTempDir" value="/Images/USERDATA" /> 
    <add key="recaptchaPublicKey" value="68888888QmJ8JvAHU" />
    <add key="recaptchaPrivateKey" value="6888888p" />
    <add key="recaptchaApiVersion" value="2" />
    <add key="vs:EnableBrowserLink" value="false" />
  
  </appSettings>

 
  <system.web>
    
   <customErrors mode="On" />
    
    
    
    <authentication mode="None" />
    
    
    
    <compilation debug="false" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2"  maxRequestLength="3096"  requestPathInvalidCharacters="" />
    
  </system.web>
  
   
  
  <system.webServer>
    

    <modules runAllManagedModulesForAllRequests="true">

      <add name="Timer" type="WEB.Utilities.TimerModule" />
      <add name="CustomServerHeader" type="WEB.Utilities.CustomServerHeaderModule" />

      <remove name="FormsAuthentication" />
      
    </modules>
    
  <httpProtocol>
  <customHeaders>
    <remove name="X-Powered-By" />
  </customHeaders>
  </httpProtocol>
  
  
   <rewrite> 
      <rules>
        <rule name="Redirect to non-www" stopProcessing="true">
          <match url="(.*)" negate="false"></match>
          <action type="Redirect" url="http://нннннн/{R:1}"></action>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^ннннн$" negate="true"></add>
          </conditions>
        </rule>
    
     
   
    
      </rules>
    </rewrite> 

    
  
          <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
          </staticContent>
          
           <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
            <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
            <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/json" enabled="true" />
            <add mimeType="*/*" enabled="false" />
            </dynamicTypes>
            <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/atom+xml" enabled="true" />
            <add mimeType="application/xaml+xml" enabled="true" />
            <add mimeType="*/*" enabled="false" />
            </staticTypes>
          </httpCompression>
          
          <urlCompression doStaticCompression="true" doDynamicCompression="true" /> 

  
  </system.webServer>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-10-24
@LifeAct

Was the project compiled? Were there any errors in the process?
Based on the route, the page should open at:
The first parameter is the name of the route to match. Then comes the template and the default values.
https://msdn.microsoft.com/en-us/library/dd504958(...
For address:
the route should be like this:

routes.MapRoute(
  "meropriyatiavnikolaeve", // имя
  "meropriyatiavnikolaeve", // шаблон
  new { controller = "Home", action = "meropriyatiavnikolaeve" }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question